0

I've read all the documentation I could find and this case is still not clear to me. When I receive a message from subscription A and then use a transaction to complete the message and send a new message to the same topic (but to a different subscription), is it necessary to configure the Service Bus client with EnableCrossEntityTransactions?

The flow:

  1. Receive message M1 from subscription A (topic T1)
  2. Start transaction
  3. Complete message M1
  4. Send message M2 to topic T1 (will be routed to subscription B)
Adam Smejkal
  • 88
  • 1
  • 10

1 Answers1

0

While the subscription used to receive is under the same topic used to dispatch to, those are two different entities.

If you want to ensure completion of M1 and dispatching of M2 are happening atomically, succeed or or rolled back together, a transaction is necessary and the option EnableCrossEntityTransactions is required. Otherwise, you're risking completing the incoming M1 message without successfully dispatching M2.

halfer
  • 19,824
  • 17
  • 99
  • 186
Sean Feldman
  • 23,443
  • 7
  • 55
  • 80
  • After reading more on how this works under the hood, I'm still confused. If I understood it correctly, all EnableCrossEntityTransactions does is setup topic T1 as the send-via entity for the sender. But the sender is already sending messages to topic T1, so I'm not sure I understand what enabling it would actually do in this case. Can you clarify please? – Adam Smejkal Nov 01 '22 at 12:57
  • It's about transactional message processing. Both completion of M1 and the dispatching of M2 need to happen atomically. If one fails, both operations need to be rolled back. That's where `EnableCrossEntityTransactions` (or `Send-Via`) comes into the game. It uses an entity for staging things and then executing. The incoming queue has a sub-queue, the Transfer queue. It's being used only when `EnableCrossEntityTransactions` is enabled. – Sean Feldman Nov 01 '22 at 16:27
  • See [Slide #42](https://www.slideshare.net/SeanFeldman3/azure-service-bus-the-messaging-backbone-for-cloud-applications) or [docs](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-transactions#transfers-and-send-via). – Sean Feldman Nov 01 '22 at 16:27