Ordered Delivery with netMSMQbinding
Asked Answered
Q

3

5

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.

Quittance answered 8/4, 2009 at 11:42 Comment(1)
I filed a connect bug on this topic, not exactly the same issue as you had, but close enough... I also have a solution in the connect bug. Check it out here: connect.microsoft.com/VisualStudio/feedback/details/1107645/…Thrombocyte
M
3

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;
    }
}
Mouse answered 8/4, 2009 at 13:17 Comment(1)
Perfect. Just the definitve answer I was looking for. I can get back to the day job now :)Quittance
E
2

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.

Eggert answered 17/8, 2009 at 11:53 Comment(1)
Actually, ReleaseServiceInstanceOnTransactionComplete has to be set to false (as said in the last post of that same thread). Setting it to true causes an activation exception in runtime. Otherwise this seems to fix the ordering.Ignominy
T
1

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

Thread answered 10/4, 2009 at 16:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.