🎄 Happy Holidays! 🥳
Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.
Happy Holidays!
Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.
Listening to events in your JavaScript/NodeJs application: Promise/Async-Await vs Callbacks
There are a bunch of Solace specific status codes that could be leveraged in callback functions in your JavaScript application or NodeJS microservice. It's a common practice in JavaScript to handle async calls in a Promise/Async-Await implementation. The majority of the Solace API functions are asynchronous but are not implemented in a promise format since the solace broker emits a variety of events handled by the API as status codes to be leveraged in call-back functions.
So for example, to check if the connection is established with the solace broker, one will have to leverage the status code SessionEventCode#UP_NOTICE
in a callback function since this event is only emitted on successful registration of a listener with the broker and could be used in the following format
solace.SessionEventCode.UP_NOTICE, function (sessionEvent) { *your logic here* }
More usecases could be found in the EventMonitor.js sample in our opensource NodeJS samples and the JavaScript samples github repos.
Let us now what events you are leveraging in your NodeJs and JavaScript applications!