2009-04-08 32 views
5

当使用WCF netMSMQbinding时可以保证有序交货吗?有订单交货netMSMQ绑定

我们在同一个队列上放入一个插入命令,后面接着一些更新命令,偶尔有一个更新会跳过插入。

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

我设法谷歌几个表明这个是正常现象的文章,但似乎它必须能够配置它以某种方式订购。

我们的队列是事务性的,所以我不认为加序列号,并在目的地重新排序是去工作,因为这将失去事务性

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

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.

我不知道为什么我们得到这个错误,因为一切“出现”要正确设置。虽然我没有设法找到允许MSMQ使用此设置的任何确认,因为它似乎是WS-RM设置,并且AFAIK netMSMQBinding不支持WS-RM。

+0

我提交的该主题的连接错误,不完全是因为你有同样的问题,但足够接近......我也有一个解决方案在连接错误。看看这里:https://connect.microsoft.com/VisualStudio/feedback/details/1107645/wcf-receives-messages-from-msmq-out-of-order – 2015-01-30 00:01:55

回答

3

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

看看System.ServiceModel.Channels.MsmqBindingElementBase + BindingDeliveryCapabilitiesHelper这是类指定MSMQ的结合能力,以及它是如何实现了物业:

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

完美。只是我正在寻找的definitve答案。我能回到现在的日常工作:) – Modan 2009-04-08 13:40:11

2

This post from 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.
  • 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.

+0

事实上,`ReleaseServiceInstanceOnTransactionComplete`必须设置为`FALSE`(如[同主题]的过去后(http://social.msdn.microsoft.com说/论坛/ EN-US/WCF /线程/ D5E62C68-08FA-492C-BA05-182EC313A54B))。将其设置为true会导致运行时出现激活异常。否则,这似乎解决了排序问题。 – htuomola 2011-12-20 12:36:12