开发者

Out of order messages possible with transactional queues in MSMQ?

开发者 https://www.devze.com 2022-12-10 22:48 出处:网络
I\'m new to messaging and a little unclear as to whether it is possible for MSMQ to deliver out-of-order messages for transactional queues. I suppose it must be because if a message is not processed c

I'm new to messaging and a little unclear as to whether it is possible for MSMQ to deliver out-of-order messages for transactional queues. I suppose it must be because if a message is not processed correctly (and since we will be using multiple "competing consumers"), then other c开发者_开发技巧onsumers could continue to process messages while the failed message is placed back on queue. Just can't seem to find a black-and-white answer anywhere on this.


  • Negative black-and-white answer are hard to find( they don't often exist).
  • You are confusing two terms here( I think). delivery is from the sender to the queue. consuming is from the queue to the consumer. Those two action can't be put in the same transaction. They are totally separate action ( this is one of the points of queuing )

More to the point: from "Microsoft Message Queuing Services (MSMQ) Tips"

That these messages will either be sent together, in the order they were sent, or not at all. In addition, consecutive transactions initiated from the same machine to the same queue will arrive in the order they were committed relative to each other.

This is the only case of order in msmq.

Sadly you won't find anything about ordered consuming because its not relevant. You can consume messages from msmq any way you want.

Update: If you must have ordered processing, than I don't see the reason to use many consumers. You will have to implement the order in your code.


Do your messages need to be processed in order because:

1) They are different steps of a workflow? If so, you should create different queues to handle the different steps. Process 1 reads Queue 1, does its thing, then writes to Queue 2, and so forth.

2) They have different priorities? If the priority levels are fairly coarse (and the order of messages within priorities doesn't matter), you should create high-priority and low-priority queues. Consumers read from the higher priority queues first.

3) A business rule specifies it. For example, "customer orders must be processed in the order they are received." Message queues are not appropriate for this kind of sequencing since they only convey the order in which messages are received. A process that periodically polls a database for an ordered list of tasks would be more suitable.

0

精彩评论

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

关注公众号