MSMQ: Does MSMQ guarantees sequential message passing?

370 views Asked by At

After load testing, I found some packets are not sequential.

it's a basic WCF service and client is continuously sending the request.

1

There are 1 answers

4
tom redfern On

It is possible to have guaranteed (in-order, exactly-once) delivery using netMsmqBinding.

The first thing you need to do is to create your actual MSMQ message queue transactional.

Secondly, you must tell WCF to enlist in the transaction like so:

[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
public void Handle(Something msg)
{
    ....
}

Lastly, you need to specify guaranteed behavior of the service by using the exactlyOnce binding paramter:

<netMsmqBinding>
  <binding name="netMsmqBinding_IMyServiceInterface" 
           exactlyOnce="true"> 
    ...
  </binding>
</netMsmqBinding>

ExactlyOnce tells WCF that we require transactions, that each message will be delivered exactly once and in the order they were sent.