Redux solace
Redux-solace wraps the solace js library into a reusable redux middleware
- It is designed for browser runtime only, not for node js runtime
- Written in Typescript
- Provide promise based Apis
- Provide flux action based Apis
- All action parameters follow the Redux/FLUX pattern
- Wrap solace api into one core class
- Support Multi-session management
- Support Publish/Subscribe to topics
- Support Queue msg
- Support request/reply msg
Quick start
Install
npm install redux-solace -S
-- or
yarn add redux-solace
Build the middleware and inject into store
User the createSolaceMiddleware
to create one middleware and add it to middleware chain.
const solaceMiddleware = ; const middleware = ; const store =
Then inject the store into your frontend freawer like (React, Angular 5/6/7)
const store = ; store; ReactDom;
All set
Make no mistake , you are now good to connect to the solace message router.
// import the session package and rename it if needed ; { const state = ; } { ; }
sample response action object
Response action could be listened like
; { // if there were any errors while creating the session, the action.error would be the error obj if !actionerror } { ; }
or a SOLACE_CONTEXT_CHANGED
action will be also emitted if sessions changed
; ; const defaultState = ...; SolaceSessionactionsSOLACE_CONTEXT_CHANGED:{ const total defaultSessionId sessionContexts } = actionpayload; return ...state total defaultSessionId sessions:sessionContexts }
Performance
A benchmark pressure test has been conducted along with a original solution using delegate server connecting solace router via websocket(socket.io). The conclusion is, using redux-solace will be 10-30ms slower on average per message than original solution using delegate server, but redux-solace brings flexibility, avoids delegate sever preprocess or schema negotiation cross teams.