2
votes

I would like to know when exactly an NServiceBus transaction ends in a specific scenario. The scenario is as follows:

  1. Message is received on a queue.
  2. Handler reads the message and loads something from the database.
  3. Handler publishes an Event to 3 subscribers.

Does the transaction (by default) end when:

  • A: The Event have been published?
  • B: Or when the Event has been published AND received by all 3 subscribers?

Note that the subscriber is not part of the system, and not necessarily using NServiceBus, or even .NET.

1

1 Answers

6
votes

It ends with a commit when all message handlers for the incoming message has been run to completion successfully(or rolls back in case of failure).

In your scenario that would be right after the event has been published and accepted by the underlying transport. For MSMQ with its store-and-forward architecture that means written to the outgoing queues for each of the subscribers. For brokered transports like RabbitMQ it would mean written to disk on the broker. (by default. You can make this more dangerous by explicitly changing options)