r/learnprogramming • u/Boring-Breadfruit251 • 3h ago
Tutorial Stand for demonstrating and exploring the Outbox and Inbox patterns
Ever wondered what happens when your service saves an order, then Kafka goes down right before the event is sent? The order exists, but nobody downstream ever hears about it.
This is the classic dual-write problem, and it’s one of those topics that separates “I know Spring Boot” from “I understand distributed systems.”
I built a small hands-on stand where you can break things on purpose and watch the patterns save the day:
Transactional Outbox: the order and its event are written in one DB transaction. A poller delivers the event to Kafka later, with retries and backoff, even if the broker was down.
Transactional Inbox: Kafka delivers at-least-once, so duplicates happen. The consumer records every event id and skips repeats. The same event delivered 3 times produces 1 notification.
What you can play with:
- Two Spring Boot services (order + notification)
- A DLQ with a REST API to inspect and retry failed events
- Diagrams, delivery guarantees explained, and a quick start with Docker
Stop Kafka, create an order, start it again, and see the event arrive. Send the same event three times and see it handled once.
If you’re learning Java and want to go beyond CRUD tutorials, this is a good next step. Feedback is very welcome!
Repo: https://github.com/dmitriy-iliyov/spring-transactional-outbox