开发者

Do I need MSDTC for NServiceBus / NHibernate?

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 q开发者_如何学运维uestion 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜