NServiceBus / NHibernate 是否需要 MSDTC?

发布于 2024-09-14 03:51:03 字数 360 浏览 2 评论 0原文

我正在编写 NServiceBus 解决方案并尝试使用 DBSubcriptionStorage。这使用 NHibernate 进行数据访问,我得到以下异常:

合作伙伴事务管理器已禁用对远程/网络事务的支持

我可以启用 MSDTC,但我的问题是:此要求从何而来,我可以删除它吗?

我对 NHibernate 不熟悉,我不知道它是否需要 MSDTC 或者 NServiceBus 是否需要。 NServiceBus 订阅数据库中只有一张平面表,我几乎看不到 MSDTC 在这种情况下的使用。

我可以删除 MSDTC 要求吗?我是否必须为此目的编写自己的订阅持久层?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぺ禁宫浮华殁 2024-09-21 03:51:03

MSDTC 是一种很棒的小动物,但也可能非常阴险。

首先,如果您知道自己不想成为分布式事务的一部分,我建议您在开发服务器上将其关闭。您不希望在 DEV 中自动升级为分布式事务,却发现它会影响您的实际性能或在生产中不起作用。

话虽这么说,答案是像 NHibernate 这样的 ORM 不会这样做,但如果满足以下条件之一,则很可能让 MSDTC 参与进来:

  • 您正在链接到另一台服务器的事务内查询视图/表。
  • 您在单个 TransactionScope 中使用两个 SqlConnections(或 NHibernate 使用的任何内容)。
  • 您在 TransactionScope 中加入了另一个事务组件(如 MSMQ 或事务文件系统)。

如果满足这些条件中的任何一个(当然还有其他一些我忘记了),您的事务将自动升级为分布式事务,并且 MSDTC 必然会参与其中。这意味着 MSDTC 不仅必须为您的盒子工作和配置,还必须为所有想要参与您的交易的盒子进行配置。在简单的 SQL Serve 场景中,这意味着您的应用程序服务器和 SQL Server 都需要运行它并针对分布式事务进行配置。

我不熟悉 NServiceBus,但我倾向于认为它具有各种功能,可以以事务方式将消息放置在队列上。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文