API Threading
The APIs use a context to organize communications between a client application and a Solace event broker. A context acts as a container for configuring one or more sessions and handling session-related events, and it encapsulates threads that drive network I/O and message delivery notification for the sessions. Message delivery and reception can also require application-provided threads.
Threading When Publishing Messages
The client application provides the processing thread required to publish Guaranteed messages to a destination on the event broker.
When the event broker successfully receives Guaranteed messages, it returns acknowledgments to the API. It does not return acknowledgments for Direct messages.
The context uses a processing thread to read the acknowledgment from the event broker. It then parses the windowed acknowledgment, enqueues separate acknowledgments for each message (identified by a message ID), then dispatches them to an application callback.
The Solace JavaScript API and Solace Node.js API are single-threaded including notification and dispatching the acknowledgments to application event listeners.
Threading When Receiving Messages
When receiving published messages, the context uses a processing thread to read messages off the socket, parse them, and then enqueue the messages for delivery or consumption, or perform customer notification and message dispatch.
Receiving Messages Asynchronously
When messages are available, they are automatically sent ("pushed") to a message event listener from the API to the client application.
The Solace JavaScript API and Solace Node.js API are single-threaded including asynchronous receiving of messages through application message event listeners.
Receiving Messages Synchronously
Receiving messages synchronously is not supported for the Solace JavaScript API and Solace Node.js API.