开发者

Preserving order of messages in WCF service with ConcurrencyMode.Multiple mode

There is a WCF service which handles incoming requests and for each incoming message produces a corresponding output message which is sent to another WCF service. The order in which messages c开发者_如何学运维ome is important and cannot be disturbed. So the service should produce the corresponding output messages in the same order in which they are received by the service. Also it's important to handle requests concurrently so that to benefit from multicore CPU.

What is the best approach to preserving order of messages between inputs and outputs in this case?


That is completely up to your implementation. WCF can only enforce ordered delivery (either through reliable session or MSMQ) so that you can be sure that messages are received in the order they were sent but there is no feature which will ensure that your operation will send messages in the same order (one message can be processed faster then another received earlier). If you want to process messages in order setting ConcurrencyMode to Multiple will only make things terribly complicated. You will have to manually synchronize operations which will reduce concurrency and in the worst case fallback close to ConcurrencyMode.Single. Synchronization can be hard to achieve because it is not enough to do it in the operation - WCF channel stack processing of output messages must also be synchronized.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜