Menu

At-Least-Once Delivery Without Double Charges: The Outbox Pattern in Plain Java
πŸ“°

At-Least-Once Delivery Without Double Charges: The Outbox Pattern in Plain Java

DEV Community: microservicesΒ·Said OlanoΒ·11 days ago
#1U1Oq8yA
#devtomicroservices#devto#dev#event#kafka
Long article (2053 words) β€” no AI summary yet.
Reading 0:00
15s threshold

Every event-driven system eventually meets the same bug. An order is saved, but the OrderCreated event never reaches Kafka. Or the event reaches Kafka twice, and the customer is charged twice.

Repository: https://github.com/josesaid/outbox-demo

Diagrams (English): https://josesaid.github.io/outbox-demo/diagrams/english/workflow-english.html

Diagramas (espaΓ±ol): https://josesaid.github.io/outbox-demo/diagrams/spanish/flujo-espa%C3%B1ol.html

Neither bug shows up in a happy-path test. They appear when a process crashes at the wrong millisecond, or when the broker is unavailable for a few seconds. To see them, you have to cause those failures on purpose.

That is what outbox-demo does. It is a small Java project with no dependencies. Kafka and the database are simulated with plain classes, so you can run it with javac and watch every step in the log. It runs five scenarios: a normal flow, a relay crash, a consumer crash, a temporary broker failure, and a permanent one.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.