MT + transactional MSMQ + NHibernate + WCF

204 views
Skip to first unread message

Marek Stój

unread,
Jul 19, 2012, 6:25:26 AM7/19/12
to masstrans...@googlegroups.com
I need some help with the following scenario.

We're in a process of experimenting with Mass Transit and trying to integrate it with an existing system based on WCF services.

We have defined a saga and we're using transactional MSMQ transport. When receiving saga events we usually do the following: save some saga data using NHibernateSagaRepository, send requests to our WCF services (using transactional MSMQ endpoints) and publish events to the MT bus.

The happy path has been great so far but we're confused about transactions handling when something goes wrong. What we would like in case of an exception is to rollback all changes made to the database, rollback all events published to the bus and rollback all messages sent via WCF.

NHibernateSagaRepository takes care of rolling back its transaction but the TransactionScope created by TransactionalInboundMsmqTransport (almost) never gets to see any consumer exceptions as they're swallowed by Endpoint.Receive() method and the MT message is moved to the error transport. All of our MT queues are created transactional so we know that even if we managed to rollback the TransactionScope created by MT we'd also undo moving the message to the error transport.

Could you advise how we should proceed to achieve the described behavior?

Dru Sellers

unread,
Jul 23, 2012, 11:43:28 AM7/23/12
to masstrans...@googlegroups.com
do you have a failing test that shows the issue????

-d



--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/8oXLckAghtoJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Marek Stój

unread,
Jul 26, 2012, 7:14:53 AM7/26/12
to masstrans...@googlegroups.com
Here's the failing test: https://gist.github.com/3181525

I'd expect that in case of an exception, the call to Publish in the ContinueSagaEvent handler would be rolled back because the queues are transactional.

Dru Sellers

unread,
Jul 26, 2012, 8:42:28 AM7/26/12
to masstrans...@googlegroups.com
Thank you, I will take a look.

On Thu, Jul 26, 2012 at 6:14 AM, Marek Stój <marek...@gmail.com> wrote:
Here's the failing test: https://gist.github.com/3181525

I'd expect that in case of an exception, the call to Publish in the ContinueSagaEvent handler would be rolled back because the queues are transactional.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstrans...@googlegroups.com.
To unsubscribe from this group, send email to masstransit-dis...@googlegroups.com.

Chris Patterson

unread,
Jul 30, 2012, 7:45:07 AM7/30/12
to masstrans...@googlegroups.com
If this is caused by Publish not throwing, that's fixed in 2.5.3.

Marek Stój

unread,
Jul 30, 2012, 9:49:50 AM7/30/12
to masstrans...@googlegroups.com
Nope, that's not it. In the situation I'm talking about, call to Publish succeeds; an exception is thrown later:

saga.Bus.Publish(new EndSagaEvent { CorrelationId = @event.CorrelationId, });
throw new InvalidOperationException();


On Monday, July 30, 2012 1:45:07 PM UTC+2, Chris Patterson wrote:
If this is caused by Publish not throwing, that's fixed in 2.5.3.

On Thu, Jul 26, 2012 at 7:42 AM, Dru Sellers <d...@drusellers.com> wrote:
Thank you, I will take a look.
On Thu, Jul 26, 2012 at 6:14 AM, Marek Stój <marek...@gmail.com> wrote:
Here's the failing test: https://gist.github.com/3181525

I'd expect that in case of an exception, the call to Publish in the ContinueSagaEvent handler would be rolled back because the queues are transactional.


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/masstransit-discuss/-/c_u_LXcC508J.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To unsubscribe from this group, send email to masstransit-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages