views:

151

answers:

1

Hi Guys,

I am writing an NServiceBus solution and trying to use DBSubcriptionStorage. This uses NHibernate for data access and I get the following exception:

The partner transaction manager has disabled its support for remote/network transactions

I could enable MSDTC but my question is: where is this requirement coming from and can I remove it?

I am not familiar with NHibernate and I don't know if it requires MSDTC or if NServiceBus does. There is only one flat table in the NServiceBus subscription database and I can hardly see the use of MSDTC in this scenario.

Can I remove the MSDTC requirement? Will I have to write my own subscription persistence layer for that purpose?

Thanks

+1  A: 

MSDTC is a great little animal, but can be quite insidious.

First off, I recommend that if you know you don't ever want to be a part of a distributed transaction, that you turn it OFF on your development servers. You don't want to automatically promote to a distributed transaction in DEV only to find out that it kills your real-world performance or doesn't work in production.

That being said, the answer is that ORMs like NHibernate do not, but it's very possible to get MSDTC involved if one of these conditions are met:

  • You're querying a view/table inside a transaction that is linked to another server.
  • You're using two SqlConnections (or whatever it is NHibernate uses) within a single TransactionScope
  • You're enlisting another transactional component (like MSMQ or the transactional file system) inside a TransactionScope.

If any of these conditions are met (surely there are some others I've forgotten about), your transaction will auto-promote to a distributed transaction, and MSDTC necessarily gets involved. That means that not only does MSDTC have to be working and configured for your box, it has to be configured for all boxes that want to participate in your transaction. In a simple SQL Serve scenario, that means your app server and your SQL Server both need to have it running and configured for distributed transactions.

I'm not familiar with NServiceBus, but I'd tend to think it would have all kinds of functionality which would transactionally place messages on, say, a queue.

Dave Markle
Thanks for this detailed information, it really helps understanding the reasons behind this. NServiceBus is based on MSMQ so that could be it..
Xavier Poinas
NServiceBus use the DTC to run the database calls and the removing of messages from its input queue in the same tx. The fact that subscriptions arrive at the same input queue as all other messages means that you'd have to give up on ACID behavior for all messages ,configure the msmqtransport to be non-transactional to achieve this, inorder to not use the DTC. That said the ability to guarantee the above consistency is IMHO one of the key selling points of NSB so would suggest that you stick with transactional queues and enable the DTC
Andreas
"First off, I recommend that if you know you don't want to be a part of a distributed transaction EVER, that you turn it OFF on your development servers"You do not give a reason for that.
Paco
@Paco: Read on to the next sentence and you will find the reason.
Dave Markle
@Andreas: That was my suspicion. Thanks for confirming it!
Dave Markle
@Dave Markle: That is not a reason, but your opinion on based on the experience you had with a specific situation. Everything has advantages and disadvantages. DTC does not kill performance per definition and it doesn't stop working per definition. There is a reason that it can kill performance in many situations. When you somebody doesn't know that reason, he is programming by coincidence.
Paco
@Paco, if you're making the argument that distributed transactions don't often incur a significant performance penalty, you might want to back that up with some evidence. Either way, it's extremely unwise to program using distributed transactions without understanding what their impact will be. If one expects to not be using them, it behooves one to turn the DTC off. That way, if they do get an auto-promotion, an error occurs and they can evaluate whether or not they really intended to enlist in a distributed transaction in the first place.
Dave Markle