Out of order messages possible with transactional queues in MSMQ?

有些话、适合烂在心里 提交于 2019-12-10 16:46:42

问题


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 consumers 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.


回答1:


  • 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.




回答2:


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.



来源:https://stackoverflow.com/questions/1668795/out-of-order-messages-possible-with-transactional-queues-in-msmq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!