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.

The Solace C API receives published messages asynchronously. See Receiving Messages Asynchronously.

Receiving Messages Asynchronously

A client application can use the Solace C API to receive messages in an asynchronous manner. That is, when messages are available, they are automatically sent ("pushed") to a message callback function from the API to the client application.

When receiving messages asynchronously, the context uses a processing thread for consumer notification and dispatching the queued messages to consumers; all callback functions from the API to the application, such as message receive callbacks, event callbacks, and timer callbacks, run from a context thread.

When a client application is using asynchronous transacted sessions, messages are dispatched from one or more transacted session dispatcher threads. Either a single transacted session dispatcher thread that is bound to the context (this is the default) or separate transacted session dispatcher threads that are that are bound to each transacted session can be used. For more information, see Using Local Transactions.

Contexts used by the Solace C API asynchronously receive messages when the MESSAGE_CALLBACK_ON_REACTOR session property is enabled. The Solace C API only uses one processing thread for the context. This thread reads messages off the socket, parses them, and then performs consumer notification and dispatches the messages to consuming applications.

For the Solace C API, the required context thread can optionally be supplied by the client application instead of relying on the internal API thread. See Solace C API Best Practices.

The figure below shows shows the context thread that is used to receive messages asynchronously through the Solace C API.

Receiving Messages Asynchronously With the Solace C API