NOTE

1.2 Message Ordering in Message Queues

English translation of the original VNote “Message Ordering in Message Queues”, preserving its current structure.

Message QueuesCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

1. What Is the Message Ordering Problem?

As shown in the figure, the producer sends two pieces of data to the message queue in sequence: insert data and update data. Suppose there are two consumer nodes. The message queue sends these two pieces of data to the consumers in a round-robin manner. Consumer 1 consumes insert data, and Consumer 2 consumes update data. In the end, the order in which they are written to MySQL becomes update data followed by insert data. In that case, when the update is executed, the row does not yet exist, so an error occurs.

Ordering Problem - Ordering Problem

2. How to Solve It

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub