Search⌘ K
AI Features

Message Delivery: Ordered Messages

Explore how message ordering impacts event processing in Golang asynchronous systems. Understand the challenges with single and multiple consumers, the risks of deadlocks, and how partitioned queues can maintain ordered delivery. Discover practical approaches to handle message processing consistency in event-driven architectures.

As with delivery guarantees, the order we will receive events comes with its own scale of guarantees of order. We can quickly find ourselves in a difficult situation if we listen to our vendor who promises that their product always delivers messages in the order they were published and later learn we are processing ProductRemoved events before the corresponding ProductAdded event.

The number of consumers we use and how we use them can have a huge impact on ordering.

  • Single consumer: A single consumer subscribed to a first-in, first-out (FIFO) queue will receive messages in the order that they were published, as depicted in the following diagram:

Single consumer receiving messages in order from a FIFO queue
Single consumer receiving messages in order from a FIFO queue

If our system were to publish messages at or below the rate it consumes them, then a single consumer would keep up and be all that we need. This is often not the case in an event-driven application. ...