使用 netMSMQ 绑定进行有序交付

发布于 2024-07-16 20:14:45 字数 726 浏览 2 评论 0原文

使用 WCF netMSMQbinding 时是否可以保证有序交付?

我们将一个插入命令后跟多个更新命令放在同一个队列上,有时其中一个更新会击败插入命令。

添加了广泛的日志记录后,很明显它们正在以正确的顺序添加到队列中,并以不同的顺序进行处理。

我已经设法谷歌了几篇文章,指出这种行为是预期的,但似乎必须可以将其配置为以某种方式订购。

我们的队列是事务性的,所以我认为添加序列号并在目的地重新排序不会起作用,因为

如果我添加属性 [DeliveryRequirements(RequireOrderedDelivery=true, QueuedDeliveryRequirements=QueuedDeliveryRequirementsMode. Require)] 我收到以下错误:

合约“IService”上的 DeliveryRequirementsAttribute 指定了 QueuedDeliveryRequirements 值为 NotAllowed。 然而,配置的 该合约的绑定指定它支持排队交付。 A 排队绑定不能与此合约一起使用。

我不知道为什么我们会收到此错误,因为一切“似乎”都设置正确。 我还没有找到任何关于 MSMQ 允许此设置的确认信息,因为它似乎是 WS-RM 设置,并且 AFAIK netMSMQBinding 不支持 WS-RM。

Is it possible to guarantee ordered delivery when using WCF netMSMQbinding?

We are putting an insert command followed by a number of update commands on the same queue, and occassionally one of the updates beats the insert.

Having added extensive logging it is clear that they are being added to the queue in the correct order and being processed in a different order.

I have managed to Google a couple of articles that state that this behaviour is expected, but it seems like it must be possible to configure it to be ordered somehow.

Our queues are transactional, so I don't think that adding sequence numbers and resequencing at the destination is going to work, as that would lose out transactionality

If I add the attribute [DeliveryRequirements(RequireOrderedDelivery=true, QueuedDeliveryRequirements=QueuedDeliveryRequirementsMode.Require)] I get the following error:

The DeliveryRequirementsAttribute on contract 'IService' specifies a
QueuedDeliveryRequirements value of NotAllowed. However, the configured
binding for this contract specifies that it does support queued delivery. A
queued binding may not be used with this contract.

I have no idea why we get this error, as everything "appears" to be setup correctly. I haven't managed to find any confirmation that this setting is allowed for MSMQ though, as it appears to be a WS-RM setting, and AFAIK netMSMQBinding does not support WS-RM.

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

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

发布评论

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

评论(3

难理解 2024-07-23 20:14:45

MSMQ 不支持有序交付,因此您不能。

看一下 System.ServiceModel.Channels.MsmqBindingElementBase+BindingDeliveryCapabilityHelper,它是指定 MSMQ 绑定功能的类,以及它如何实现该属性:

bool IBindingDeliveryCapabilities.AssuresOrderedDelivery
{
    get
    {
        return false;
    }
}

MSMQ does not support ordered delivery, hence you can not.

Take a look at System.ServiceModel.Channels.MsmqBindingElementBase+BindingDeliveryCapabilitiesHelper which is the class specifying MSMQ's binding capabilities, and how it implements that property:

bool IBindingDeliveryCapabilities.AssuresOrderedDelivery
{
    get
    {
        return false;
    }
}
忱杏 2024-07-23 20:14:45

Simon Gittins 的这篇文章< /a> 看起来表明可以进行有序交付:

事实证明,有一个未记录的功能可以处理这种情况:

  • 将批量大小为 ONE 的 TransactedBatchingBehavior 应用到服务端点。
  • 服务实现上的ReleaseServiceInstanceOnTransactionComplete 必须设置为true。

完成这两件事后,我的测试程序就不再产生无序消息。

This post from Simon Gittins looks like it suggests that ordered delivery is possible:

As it turns out, there's an undocumented feature that deals with this situation:

  • Apply a TransactedBatchingBehavior with a batch size of ONE to the service endpoint.
  • ReleaseServiceInstanceOnTransactionComplete must be set to true on the service implementation.

Once these two things are done, my test program no longer produces out of order messages.

书信已泛黄 2024-07-23 20:14:45

看起来您可以对消息进行分组,因此您可以在合同中指定顺序。 请查看这篇有关对邮件进行分组的 MSDN 文章

Looks like you can group messages, so therefore you could specify the order in the contract. Check out this MSDN article on grouping messages.

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