Ordered Processing of Messages in Single Concurrency Mode

WCF makes no guarantees about the order in which messages are processed, unless the underlying channel is sessionful. For instance, a WCF service that uses MsmqInputChannel, which is not a sessionful channel, will fail to process messages in order. There are some circumstances where a developer may want the in order processing behavior but not want to use sessions. This topic describes how to configure this behavior when a service is running in Single Concurrency Mode.

In-order Message Processing

A new attribute called EnsureOrderedDispatch has been added to the ServiceBehaviorAttribute. When EnsureOrderedDispatch is set to true and ConcurrencyMode is set to Single messages sent to the service will be processed in order. The following code snippet illustrates how to set these attributes.

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, EnsureOrderedDispatch = true )]  
    class Service : IService  
    {  
         // ...  
    }  

If ConcurrencyMode is set to any other value, an InvalidOperationException is thrown.

See Also

Sessions, Instancing, and Concurrency
Concurrency