Transactional Outbox and Inbox in Spring Boot
A polling-based transactional outbox and inbox for Spring Boot, taken apart: how events leave the database, why the polling delay adapts, why each event type gets its own settings, and the three clocks that decide how long a duplicate is remembered. The write that has two destinations I wrote a transactional outbox for two of my own projects. The existing options did not fit, and log-based CDC…
The article discusses the Transactional Outbox and Inbox feature in Spring Boot, which addresses the problem of publishing events from a database transaction. The outbox pattern ensures that events are part of the same transaction as the business data, preventing data from being changed without the corresponding event being published.
The outbox consists of two destinations: the business data and a separate outbox_events table. Publishing is a separate, retryable step that cannot lose events because they are already durable. The outbox includes four background jobs to manage event processing, and each event type has its own polling schedule. The library adapts the polling delay based on the workload using an adaptive strategy, with a minimum delay of 250ms, a multiplier of 1.5, and a maximum delay of 1 minute.
This approach ensures that events are delivered at least once, avoiding both lost and duplicate messages.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.