IntermediateEvent-driven
Some orders never reach the warehouse
The order service commits to its database, then publishes to Kafka. Sometimes only one happens.
The setup today
When an order is placed, the order service writes it to Postgres and then publishes order_placed to Kafka for the warehouse and others.
Current configuration
BEGIN; INSERT INTO orders ...; COMMIT;
producer.send("orders", order_placed) # after the commit
producer: acks=all, enable.idempotence=trueWhat you know
- About 1 in 50,000 orders never reaches the warehouse. Each one lines up with a deploy, a crash or a Kafka timeout right after the commit.
- An earlier version published before committing and sometimes announced orders that were then rolled back.
The new requirement
The warehouse must receive every committed order, and never an order that was rolled back.
Make the call
2 questions · first-try answers earn the most XP
What a strong answer also covers
- Key events by order ID so all of an order's events stay in order in one partition.
- Change data capture reads the database log and avoids polling load, at the cost of running a connector.
- Clean up or partition the outbox table, or it grows forever.
- Monitor relay lag: the age of the oldest unpublished outbox row.