Transactions

Transactions in Azure Service Bus are a wide topic referring to many different entities, which you can work with in this service:

  • Clients (QueueClient, TopicClient)
  • Messages (by using operations like Complete, Defer, Abandon , and many more)
  • Sessions (GetState/SetState)

As you can see, there are no receive operations listed; this is because there is an assumption that they are atomic by design.

In general, there is a requirement for using the ReceiveMode.PeekLock mode when pulling messages and opening a transaction scope inside a loop or an OnMessage callback.

You can refer to the following code snippet to get a better picture of what we are talking about in this section:

var message = receiver.Receive();using (scope = new ...

Get Hands-On Azure for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.