Grokking Microservices Design Patterns
Vote

0% completed

Transactional Outbox: An Example

The earlier lessons explained why the outbox works. This lesson shows the pattern in code. We follow one order through three short Java classes. The first writes the order and the event. The second publishes the event. The third consumes it safely.

The Write Path

OrderService.placeOrder(order) does the whole write path. It saves the order row and the outbox row in one local transaction. Either both rows commit together or neither one exists.

public class OrderService { private final OrderRepository orderRepository;

.....

.....

.....

Like the course? Get enrolled and start learning!