NOTE
1.2 Message Ordering in Message Queues
When insert and update messages reach different consumers, execution can differ from sending order. These notes use that example to examine message ordering.
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.

2. How to Solve It
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub