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 (for the C API), or message receive delegate (for the .NET API).
  • 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 example, calling solClient_flow_sendAck() (for the C API) has no effect on transacted sessions. For information on how to receive Guaranteed messages synchronously or asynchronously, see Receiving Guaranteed Messages.

For the C and .NET APIs, when a consumer flow is created, it is in a start state. The start/stop state of a consumer flow can be set through the flow properties.

To Create a Consumer Flow in a Transacted Session

PubSub+ Messaging API Call

Java RTO

TransactedSessionHandle.
createFlowForHandle(...)

C

solClient_transactedSession_createFlow(...)

.NET

ITransactedSession.CreateFlow(...)

To Synchronously Consume Messages in a Transaction

PubSub+ Messaging API Call

Java RTO

FlowHandle.receive(...)—Receives a message from the specified flow. The API waits until a message is received or it reaches the specified timeout value.

C

solClient_flow_receiveMsg(...)—Receives a message from the specified flow. It waits until it reaches a specified timeout value or a message is received. If the timeout value is 0, there is no wait. A client application must later call solClient_msg_free() on the received message to release it.

.NET

ITransactedSession.receive(...)—Receives a message from the specified flow. It waits until it reaches a specified timeout value or a message is received. If the timeout value is 0, there is no wait. A client application must later call Dispose() on the received message to release it.

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).)