在 WCF (MSMQ) 服务中禁用 DTC

发布于 2024-11-25 03:05:57 字数 580 浏览 0 评论 0原文

我正在使用 MSMQ 端点。 我已在我的服务上设置了以下属性。

[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void MyMethod(MyParam param) { ... }

在我的界面上,

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, ReleaseServiceInstanceOnTransactionComplete = true)]

我有一个方法可以更新 SQL Server 数据库,并且始终使用 MSDTC 并提升事务。

我该如何压制这个。如何连接到位于与 MSMQ 事务完全独立的事务中的 SQL Server。我只想要 sql 事务,而不是 DTC 事务。有没有办法保证sql事务不包含在MSMQ事务的范围内。

我希望我可以在不完全删除 MSMQ 上的事务的情况下做到这一点,这正是我正在考虑的。

问候

克雷格

I am using an MSMQ endpoint.
I have set the following attributes on my service.

[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void MyMethod(MyParam param) { ... }

On the interface I have

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, ReleaseServiceInstanceOnTransactionComplete = true)]

I have a method that makes an update to a sql server database and MSDTC is always used and the transaction is promoted.

How do I suppress this. How do I make a connection to sql server that is in a completely SEPARATE transaction to the MSMQ transaction. I want a sql transaction only, not a DTC transaction. Is there any way to ensure that the sql transaction is not included in the scope of the MSMQ transaction.

I am hoping I can do this without removing transactioning completely on MSMQ which is what I am considering.

Regards

Craig

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

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

发布评论

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

评论(1

魂牵梦绕锁你心扉 2024-12-02 03:05:57

您在抱怨事务性 MSMQ 的核心含义。事务性 MSMQ 使用事务性读取和写入队列。因此,您的消息在事务中被读取,如果其读取/处理失败,则回滚读取并且消息不会从队列中删除。通过使用 TransactionScopeRequired 标记您的操作,您将告诉 WCF 您的操作操作是消息事务处理的一部分。如果您的数据库操作失败,MSMQ 读取也会失败,但您的消息不会丢失。如果您在操作中打开数据库连接,事务将提升为 DTC,因为您在单个事务中拥有两个事务资源。

因此,如果您不想要这种机制,请不要使用事务队列,但要仔细考虑。关闭事务队列的原因应该是你不需要它而不是你不想要分布式事务。

You are complaining about core meaning of transactional MSMQ. Transactional MSMQ uses transactional reading and writing to the queue. So your message is read in the transaction and if its reading / processing fails reading is rolled back and message is not deleted from the queue. By marking your operation with TransactionScopeRequired you are telling WCF that your operation is part of message's transactional processing. If your database operation fails it will fail MSMQ reading as well and your message is not lost. If you open database connection in your operation transaction will be promoted to DTC because you have two transactional resources in single transaction.

So if you don't want this mechanism don't use transactional queue but think about it carefully. The reason for turning off transactional queue should be that you don't need it not that you don't want distributed transactions.

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