Thursday, August 26, 2010

Ordered Message processing


Get messages in to queue.

Check the version of message. If we receive (Out of sequence) higher version message ahead of original message, Then put same in Delay queue.

If we receive initial message then figure out all higher versions from delay queue and then process it.

1. Resequencer :

The Resequencer can receive a stream of messages that may not arrive in order. The Resequencer contains in internal buffer to store out-of-sequence messages until a complete sequence is obtained. The in-sequence messages are then published to the output channel. It is important that the output channel is order-preserving so messages are guaranteed to arrive in order at the next component. Like most other routers, a Resequencer usually does not modify the message contents.

From internet:
----------------------

The only way to ensure that messages are processed in the same order as they are created is to ensure you only have one Message Producer and one Message Consumer.


Basically the messages will only maintain the order they are put on and taken off the queue, after that its a bun fight as to which Message Consumer runs. If you worried about performance then the only solution is to have multiple message streams, it's probably easier if I give an example.


I once developed an Order processor that required each order for the same customer to be processed sequencially so I create 10 queues (you can have any number) with 10 Message Consumers, one bound to each queue. Unfortunately you can still only have one Message Producer which does a hash on the Customer Id to ensure that all the messages for same Customers went onto the same queue.

No comments:

Post a Comment