Rolling Back Whole Chain of Messages

Hello All,

I have a question about the NSB pipeline.
If I have chain of messages that are handled async, and one of the messages fail down the line, is there a way to rollback all the messages that got processed already?

example:

Handler(Message1)
{
// commit changes to DB
Publish(Message2)
}

Handler(Message2)
{
// commit changes to DB
Publish(Message3)
}

Handler(Message3)
{
// Message fails
}

Messages 1 and 2 were processed, but 3 failed.

Hey Mike,

If what you’re trying to achieve is that the consequences of handling those 3 messages are “atomic” than you need to move to a saga to coordinate among those 3 messages and publish or do whatever needs to be done only when you received them all.

That being said can you give us more details on the business process you are modeling?

Thanks,

.m

These handlers aren’t directly related to each other. The handlers are in different endpoints and are committing boundary specific data, but all handlers are part of the same transaction.
I want to be able to bubble up failures and roll back completed messages. Basically, commit all or commit nothing mechanism

There isn’t really a way to achieve that level of transactionality in a distributed system, your best option is to model one or more sagas at each endpoint and use events to coordinate compensation needs if something goes badly at one of the endpoints while handling one of the messages.

.m