Overview
A change data capture pipeline usually works in testing and fails in production at the queue and the consumer, not at the capture. AceMQ reviews the whole path from the connector's output to the consumer's write and fixes ordering, retries and poison events as one design.
Challenge
Change events for the same row arrive at a consumer out of order, so an older update overwrites a newer one. A single event the consumer cannot parse is redelivered again and again and everything behind it waits. When the broker restarts, the connector stops and nobody is sure whether events were lost or repeated. The team can see symptoms in three systems and a cause in none of them.
Environment
Debezium Server publishing to RabbitMQ exchanges from a relational database, running on Kubernetes, with quorum queues and several consumer services writing to their own stores.
Approach
AceMQ reads the connector settings, the exchange and queue layout, the consumer code paths and the broker's delivery behaviour for the RabbitMQ version in use. Ordering is addressed first: queue and consumer settings that keep events for one row in sequence. Poison events are then routed to a dead-letter queue with a delivery limit, and restart behaviour is tested with the connector, the broker and the consumer in turn.
Solution
- Consumer prefetch and concurrency review, with a prefetch of 1 and one active consumer per queue where order matters
- Routing keys and queue layout so one table's events reach one consumer
- Dead-letter exchange, delivery limit and at-least-once dead-letter strategy on quorum queues, with the RabbitMQ 4.3 change to how negative acknowledgements count toward the limit taken into account
- A dead-letter queue alert and a written procedure to inspect, correct and replay events
- Idempotent consumer writes keyed on the primary key, because delivery is at least once
- Offsets on persistent storage and a rehearsed restart of the connector, the broker and the consumer
- A trace identifier carried in a message header and logged by each consumer
Outcome
The engagement delivers a written design for ordering, retry and dead-lettering, the changes applied with the team's engineers, test results for broker restart, connector restart and a deliberate poison event, and runbooks for the dead-letter queue. The risk removed is a pipeline that stalls behind one bad event or silently applies events out of order.