简体   繁体   中英

MSMQ: Does MSMQ guarantees sequential message passing?

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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