A healthcare provider is building a system to process patient medical records. Due to compliance regulations, all operations that modify a patient's record must be treated as a single, atomic unit of work. This means either all steps of the operation succeed, or none of them do, and the message should not be visible to other consumers during this process. The system uses Azure Service Bus for messaging. Which Service Bus feature ensures this transactional behavior for message processing?
- AMessage sessions
- BDead-lettering
- CTransactions
- DBatched sends
Show answer & explanationAnswer & explanation
Correct answer: C. Transactions
Azure Service Bus Transactions allow you to group a series of operations (e.g., sending a message, completing a message, sending a message to another entity) into an atomic scope. If any operation fails, all operations within the transaction are rolled back. This ensures 'all-or-nothing' processing required for atomicity. Sessions provide ordered delivery, batched sends optimize throughput, and dead-lettering handles unprocessable messages, none of which guarantee atomicity.
Why the other options are wrong
- A. Message sessions ensure ordered processing of related messages by a single receiver but do not inherently provide transactional atomicity across multiple operations.
- B. Dead-lettering is a mechanism for handling messages that cannot be delivered or processed, not for ensuring transactional atomicity of processing logic.
- D. Batched sends group multiple messages into a single operation for efficiency but do not guarantee transactional integrity of subsequent processing steps.
Azure Service Bus Transactions
Azure Service Bus Transactions allow you to group a set of operations (sends, completes, abandons, dead-letters) against one or more Service Bus entities into an atomic scope. All operations within the transaction either succeed or fail together.
- Provides 'all-or-nothing' atomicity for message operations.
- Supports operations across multiple Service Bus entities within a transaction.
- Ensures data consistency and integrity.
- Useful for complex message flows requiring strict reliability.
Memory trick: A transaction is an atomic bomb: either everything explodes (succeeds) or nothing does (fails).