Completing Transactions
Messages that are published and received on a transaction are staged on the Solace PubSub+ event broker. A transaction can either be:
- Completed through a commit operation: Committing Transactions
- Canceled through a rollback operation: Rolling Back Transactions
Committing Transactions
When a commit is successfully invoked for a transaction, the following occurs:
- for publish operations, the staged messages are sent to their destinations
- for receive operations, the received messages are acknowledged by the consumers and then removed from the endpoints they were spooled to
Commits are blocking operations. After these actions, the transaction is completed, and the next transaction automatically begins.
If a commit fails for any reason (for example, due to failures of previous send and/or receive operations), a rollback of the entire transaction will occur. A rollback exception or error and a specific subcode will be generated. The failure cause can be determined from the subcode.
PubSub+ Messaging API | Call |
---|---|
Java RTO |
TransactedSessionHandle.commit() |
C |
solClient_transactedSession_commit() |
.NET |
TransactedSession.commit() |
Rolling Back Transactions
Instead of completing an active transaction through a commit, a client can rollback the transaction. When a rollback is performed, the following occurs:
- staging information for the active transaction is removed, so that:
- for publish operations, the published messages are deleted
- for consume operations, messages remain on the endpoints they were spooled to
- a new transaction is automatically generated
Rollbacks are blocking operations.
If a transacted session fails due to a network failure or an event broker reset, the client can immediately reconnect (this is automatic if the number of reconnect retries for the client connection is greater than zero), and, if possible, the API reestablishes the transaction that was in progress. If the session and transaction are not reestablished within three minutes, the event broker automatically rolls back the transaction that was in progress. (For more information about setting client reconnect properties, see Configuring Connection Time-Outs and Retries.)
PubSub+ Message API | Call |
---|---|
Java RTO |
TransactedSessionHandle.rollback() |
C |
solClient_transactedSession_rollback(...) |
.NET |
TransactedSession.rollback(...) |