Threading When Receiving Messages
When receiving published messages, the context uses a processing thread to read messages off the socket, parse them, and then, depending on the Solace Messaging API and whether a synchronous or asynchronous mode is used, enqueue the messages for delivery or consumption, or perform customer notification and message dispatch.
Client applications can use one of the following modes to receive published messages:
- Asynchronous
Client applications can use the Solace Messaging API for Java RTO, C, and .NET to receive published messages asynchronously. See Receiving Messages Asynchronously.
- Synchronous
The Solace Messaging API for Java RTO, C, and .NET can only receive messages asynchronously. Client applications can use the Solace JCSMP API to receive published messages synchronously. See Receiving Messages Synchronously.
Receiving Messages Asynchronously
A client application can use the Solace Messaging API for Java RTO, C, and .NET to receive messages in an asynchronous manner. That is, when messages are available, they are automatically sent ("pushed") to a message callback or message delegate interface 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 callbacks 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.
Solace Messaging API for Java RTO, C, and .NET
Contexts used by the Solace Messaging API for Java RTO, C, and .NET asynchronously receive messages in a way similar to that used by JCSMP when the MESSAGE_CALLBACK_ON_REACTOR session property is enabled. The Solace Messaging API for Java RTO, C, and .NET only use 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 Messaging API for Java RTO, C, and .NET.
Receiving Messages Asynchronously With the Solace Messaging API for Java RTO, C, and .NET
Receiving Messages Synchronously
The Solace Messaging API for Java RTO, C, and .NET can only receive messages asynchronously.