Why queue priority / FIFO in message queue?

One option for a message provider is Message Queue , which provides FIFO ordering, i.e. queue. Why is it important to organize messages? I wonder if it's because of message priority or something similar. I would appreciate it if someone could explain with an example.

+3


source to share


3 answers


Your answer is correct - logically, some operations are interdependent and you must maintain the order of the calls.

But I think there is an even more important purely technical aspect that I want to point out: you need to know the order in order to be able to execute ACID transactions.

Run the following script:



You have a process service that organizes 5 other entity / service services. The process starts and starts, but the third call fails. Most often it is too expensive to have a common transactional context between services (to ensure two-phase commit), so the solution is to use Compensation, that is, to invoke opposite operations of all services that have already performed a write operation before failure. If you cannot guarantee the order of the messages, you cannot know what you need to undo and what not (unless you explicitly look into the underlying systems and track the change yourself, which is not a sane approach).

Hope this helps!

+5


source


Here's what I wrote for my answer:

By implementing the queue data structure, Consumers will receive the messages in which they were sent. For example, an ordering system in corporate systems sends messages to the sales system. Let it be "GetPayment" and "Make a shipment". If these messages are not queued, the sales system may crash by notifying "Make a shipment" before "Receiving payment".



The idea is to keep the workflow at the enterprise level.

PS : Plamen has a more detailed answer.

+1


source


First of all, you first need to serve whatever goes into the message buffer. Message queues are used to maintain the order of received messages. Queues - first and first.

0


source







All Articles