简体   繁体   English

使用netMSMQbinding的有序交付

[英]Ordered Delivery with netMSMQbinding

Is it possible to guarantee ordered delivery when using WCF netMSMQbinding? 使用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. 我已经在Google上写了几篇文章,指出这种行为是可以预期的,但是似乎必须可以将其配置为以某种方式进行排序。

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: 如果添加属性[DeliveryRequirements(RequireOrderedDelivery=true, QueuedDeliveryRequirements=QueuedDeliveryRequirementsMode.Require)]出现以下错误:

The DeliveryRequirementsAttribute on contract 'IService' specifies a QueuedDeliveryRequirements value of NotAllowed. 合同“ IService”上的DeliveryRequirementsAttribute指定QueuedDeliveryRequirements值为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. 我尚未设法确认此设置允许用于MSMQ,因为它似乎是WS-RM设置,并且AFAIK netMSMQBinding不支持WS-RM。

MSMQ does not support ordered delivery, hence you can not. MSMQ不支持有序交付,因此您不能。

Take a look at System.ServiceModel.Channels.MsmqBindingElementBase+BindingDeliveryCapabilitiesHelper which is the class specifying MSMQ's binding capabilities, and how it implements that property: 看一下System.ServiceModel.Channels.MsmqBindingElementBase + BindingDeliveryCapabilitiesHelper,它是指定MSMQ的绑定功能的类,以及如何实现该属性:

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

This post from Simon Gittins looks like it suggests that ordered delivery is possible: Simon Gittins的这则帖子似乎表明可以订购送货:

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. 将批处理大小为ONE的TransactedBatchingBehavior应用于服务端点。
  • ReleaseServiceInstanceOnTransactionComplete must be set to true on the service implementation. 必须在服务实现上将ReleaseServiceInstanceOnTransactionComplete设置为true。

Once these two things are done, my test program no longer produces out of order messages. 完成这两项操作后,我的测试程序将不再产生乱序消息。

Looks like you can group messages, so therefore you could specify the order in the contract. 看起来您可以对消息进行分组,因此可以在合同中指定订单。 Check out this MSDN article on grouping messages . 查阅有关分组消息的MSDN文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM