Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequential processing of messages

Tags:

rebus

In Rebus, is there a way of controlling the processing of messages in such a way that messages are processed sequentially ? i.e first one processed, then removed then second processed etc

like image 686
Paul Marshall Avatar asked Sep 09 '26 11:09

Paul Marshall


1 Answers

Yes - and no :)

First off, I just want to say that it is best that you do everything in your power to design your system in a way that it becomes tolerant to reordered messages. You will be much happier in the future if your system is capable of ending up in a consistent state even though one or more messages were parked in an error queue for a while along the way.

And when I say "tolerant to reordered message", I don't necessarily mean "all messages in totally random order"... more like "slightly reordered" and/or "a few of them required to be in order, but can tolerate many of them reordered". Within reason.

It sounds to me like your requirement is pretty strict - and the only way to achieve that, is to have one single thread (with a parallelism of 1) processing messages, discarding (or moving to the back of the queue if the messages are important) messages that were not expected to be next.

If moving messages to the back of the queue is too crude (it can become slow if you have many messages, or if they often arrive out of order), you can use a saga to queue up messages until you have the right message, and at that point in time you can do what you need to do.

I hope that makes sense :) please let me know if something is not clear.

like image 129
mookid8000 Avatar answered Sep 13 '26 06:09

mookid8000



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!