Threading When Publishing Messages in the Solace JCSMP API
When the event broker successfully receives Guaranteed messages, it returns acknowledgments to the Solace JCSMP API. It does not return acknowledgments for Direct messages. (The exception to this is publishing Direct messages using JCSMP’s non-streaming publishing mode.)
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.
When publishing messages using the streaming publishing mode, a Context uses one thread to read the windowed acknowledgment that the event broker sends for a group of consecutive Guaranteed messages, parse it and then enqueue separate acknowledgments on the producer notification dispatcher queue for each message. This queue is also used for message publishing exceptions. There is one queue for each Context.
The Context uses another thread for notification and dispatching the queued acknowledgments to an application callback.
Note that if there is not enough space on the queue when the thread attempts to append notifications to it, the thread can block until there is sufficient space. The queue size can be modified through JCSMPGlobalProperties. setProducerDispatcherQueueSize().
The following figure shows the application thread used to send Guaranteed messages and the Context threads that are used handle a windowed message acknowledgment from the event broker.
Publishing Guaranteed Messages Through JCSMP Using a Streaming Mode