tags:

views:

271

answers:

2

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.

Cheers

+1  A: 
  • 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.

Igal Serban
Thanks for the link. Yea, it's still a bit fuzzy for me. Esp not sure whether I need to implement a 'Resequencer' when I have multiple competing consumers reading off a queue and I _must_ process messages in order
Andrew Smith
A: 

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.

Jeff Sternal
No. 3 is nearest match. I will use messages to build up a denormalised view of data for reporting off of but I also to keep track of the changes between domain events to enable syncing (need to store diffs). So, ordering is crucial. There are many views, with potentially large no of updates to each at peak times so I want to spread the load over multiple consumers. Hope that makes sense
Andrew Smith