Transactions are execution scopes in the context of transaction processing. A transaction groups two or more operations together. The goal of a transaction is that the result of this group of operations has a common outcome.
Azure Service Bus is a transactional message broker and ensures transactional integrity for all internal operations against its message stores and the respective indices. All transfers of messages inside of Service Bus, such as moving messages to a Dead-Letter Queue or automatic forwarding of messages between entities are transactional.
From a consumer perspective, Service Bus supports grouping operations against a single messaging entity (queue, topic, subscription) within the scope of a transaction. You can, for instance, send several messages to one Queue from within a transaction scope, and the messages will only be committed to the Queue's log when the transaction successfully completes.
The operations that can be performed within a transaction scope are:
- QueueClient, MessageSender, TopicClient:
- Send, SendAsync
- SendBatch, SendBatchAsync
- BrokeredMessage:
- Complete, CompleteAsync
- Abandon, AbandonAsync
- Deadletter, DeadletterAsync
- Defer, DeferAsync
- RenewLock, RenewLockAsync
- MessageSession:
- SetState, SetStateAsync
- GetState, GetStateAsync
Transactions that span multiple Service Bus entities require using a special API gesture. You may, for instance, want to receive/complete a message from one queue and send it to a different queue within a single transaction scope. That is done using transfers (EnableCrossEntityTransactions).