Consuming Messages in Transactions
To consume Guaranteed messages in a transaction, a client must create a consumer flow within the transacted session through one of the methods or functions listed below to bind to the destination endpoint that the messages are spooled to.
Guaranteed messages can then be received from the destination endpoint through the consumer flow either:
- asynchronously, through a message receive callback.
- synchronously, through individual receive calls. The calls required to synchronously consume messages in a transaction are listed below.
Consumers in a transacted session function the same as those in a non‑transacted session, except that the messages they receive are only acknowledged, and subsequently removed from the event broker, when a successful commit occurs for the transacted session. For information on how to receive Guaranteed messages synchronously or asynchronously, see Receiving Guaranteed Messages.
To Create a Consumer Flow in a Transacted Session
In the Solace Java RTO API, use TransactedSessionHandle.createFlowForHandle(...)
To Synchronously Consume Messages in a Transaction
In the Solace Java RTO API, use FlowHandle.receive(...)—Receives a message from the specified flow. The API waits until a message is received or it reaches the specified timeout value.
When the following situations occur after the messages are consumed in a transaction, but before a commit is made, those messages are still successfully committed:
- The messages are removed from the event broker by an administrative action (that is, the messages are deleted from the spool).
- The messages' TTLs have expired. (Note that the commit succeeds whether or not expired messages are moved to a dead message queue (DMQ).)