Quick revision
The short answer
I would standardise one pattern: a transactional outbox with a shared table schema and a supported relay or CDC pipeline, with no new XA except approved cases. It ships as a Spring Boot starter with tests, metrics and documentation, defines at-least-once delivery plus idempotent consumers with an inbox table, and is owned by a platform team with an SLO. Existing teams migrate opportunistically, money and inventory flows first, without forced rewrites that bring no benefit.
What to remember
In this answer, we turned several home-grown mechanisms into one standard. We inventoried what exists, chose the transactional outbox with one shared schema and a supported relay or CDC pipeline, allowed new XA only by exception, defined the contract as at-least-once with idempotent consumers and an inbox table, shipped it as a Spring Boot starter with tests and metrics, migrated money and inventory flows first without forcing other rewrites, and gave the relay platform to a team with an SLO.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would standardise one pattern: a transactional outbox with a shared table schema and a supported relay or CDC pipeline, with no new XA except approved cases. It ships as a Spring Boot starter with tests, metrics and documentation, defines at-least-once delivery plus idempotent consumers with an inbox table, and is owned by a platform team with an SLO. Existing teams migrate opportunistically, money and inventory flows first, without forced rewrites that bring no benefit.
Why this question is asked
When teams solve the same hard problem independently, each solution has its own bugs, its own gaps in monitoring, and its own on-call knowledge that leaves with one engineer. Atomic state change plus event publication is a classic case: some teams use XA, some wrote outbox pollers, some have retry tables. Interviewers ask this at the fifteen-year level because the technical choice is the easy part; the hard part is picking a standard people will adopt and rolling it out without stopping delivery. In this answer, we will take stock of what exists, choose what to standardise and why, define the delivery contract, describe how we ship it, and plan the rollout and ownership.
1Taking Stock of What Exists
Before choosing, we inventory. For each team's mechanism we record what it guarantees, how it fails, what it costs to run and who understands it. A typical result: two services on XA with a JTA transaction manager, which work but cannot scale freely on Kubernetes; four custom outbox relays, each with a different table, one of which does not lock rows and publishes duplicates when two pods run; and several retry tables that re-send failed messages but lose events when the process dies between the database commit and the send.
The inventory is also how we build trust. Teams see that we understand why they built what they built, and the incident history attached to each mechanism makes the case for a standard better than any principle.
2Choosing What to Standardise
We standardise the transactional outbox: the service writes its business change and an event row to an outbox table in the same local database transaction, and a relay publishes the row afterwards. It works with every database we use, needs no XA support, runs on ordinary Kubernetes Deployments, and its failure mode is a duplicate, never a loss.
We define one outbox table schema, so tooling and dashboards work everywhere, and support two relay options: an in-process relay from the starter for small services, and a CDC pipeline, for example Debezium reading the database log, for high-volume ones. New XA usage is not allowed except through an approved exception, for example a legacy integration with a resource that cannot be made idempotent.
Notice that the same schema serves both relays: the in-process relay polls unsent rows, while CDC reads inserts from the log and can ignore sent_at.
3Defining the Delivery Contract
A standard must state its guarantee in one sentence that every team can rely on. Ours is: every committed change produces its event at least once, in order per aggregate id, and every consumer must be idempotent. At-least-once means duplicates happen, after a relay crash or a consumer rebalance, so the standard also covers the consumer side: an inbox table, a dedup table of processed event ids written in the same transaction as the consumer's own change, provided by the same starter.
Being explicit removes a whole class of arguments. No team needs to ask whether exactly-once is guaranteed, because the contract says it is not, and says what to do instead.
- Service codebusiness change + outbox insert in one transaction
- Spring Boot starteroutbox writer, inbox dedup, metrics, tests
- Relayin-process poller or CDC connector
- Event platformKafka topics, schema registry, keys by aggregate id
- Platform teamowns relay and CDC, SLO on outbox lag
5 layers, from the top down. Step through them one at a time.
4Shipping It as a Starter, Not a Document
Teams adopt what is easy. So the platform ships a Spring Boot starter that contains the outbox writer, the relay, the inbox for consumers, Flyway migrations for both tables, and metrics already exposed through Micrometer: outbox lag, the age of the oldest unsent row, failed publishes, and duplicates skipped by the inbox. It includes a test kit that lets a team prove in an integration test that a crash between commit and publish still delivers the event, and that a redelivered event is processed once.
Documentation explains the contract with examples, and a reference service in the golden-path template shows the pattern from end to end. A team starting a new service gets the outbox without making a decision.
5Rolling It Out and Owning It
We do not force rewrites. New services must use the standard. Existing services migrate when they are already changing the relevant code, or when their current mechanism has caused incidents. We prioritise money and inventory flows, payments, refunds, ledger entries, stock reservations, because a lost or duplicated event there costs the most. A working custom outbox in a low-risk reporting service can stay until it is next touched.
The relay and the CDC pipeline are owned by a platform team with an SLO, for example 99 percent of events published within 5 seconds of commit, measured and reported monthly. Without an owner, a shared relay becomes everyone's dependency and nobody's job, and teams will drift back to their own solutions.
6Follow-up questions
How would you measure adoption and success?
Adoption is the share of services that publish events through the standard, tracked per quarter, with money and inventory flows reported separately. Success is about outcomes: the number of incidents caused by lost or duplicated events, the outbox lag SLO being met, and the number of custom relays and XA setups left. I would also ask teams how long it took to add a new event to a service, because the standard should make that faster, not slower.
Why not standardise on Kafka transactions instead?
Kafka transactions give exactly-once for read-process-write inside Kafka, but synchronizing them with a database is still two commits, so a crash between them can lose an event. They also tie the standard to Kafka. The outbox works with any broker and makes the database the single commit point.
What would you do with a team that refuses to migrate?
If their mechanism works and is not in a high-risk flow, nothing urgent. I would ask them to expose the same metrics so we can see it, and plan migration when they next change that code. If it is in a money flow and has caused incidents, I would bring the incident data to their leadership and agree a date.
7Conclusion
In this answer, we turned several home-grown mechanisms into one standard. We inventoried what exists, chose the transactional outbox with one shared schema and a supported relay or CDC pipeline, allowed new XA only by exception, defined the contract as at-least-once with idempotent consumers and an inbox table, shipped it as a Spring Boot starter with tests and metrics, migrated money and inventory flows first without forcing other rewrites, and gave the relay platform to a team with an SLO.
Open with
I would start with an inventory of what each team built, what it guarantees and what incidents it has caused, because that data makes the case for a standard.
Then, if they want more
Then I would standardise one pattern: the transactional outbox, with one shared table schema, and two supported relays, an in-process poller for small services and a CDC pipeline such as Debezium for large ones. New XA would need an approved exception.
I would make the delivery contract explicit: every committed change is published at least once, in order per aggregate id, and every consumer must be idempotent using an inbox or dedup table written in the same transaction as its own change.
I would ship all of this as a Spring Boot starter with migrations, metrics for outbox lag and failed publishes, a test kit that proves crash and redelivery behaviour, and documentation with a reference service in the golden-path template.
The rollout would be opportunistic: new services must use it, existing services move when they change that code, and money and inventory flows go first because duplicates and losses cost the most there. I would not force rewrites that bring no benefit.
Finally a platform team owns the relay and CDC with an SLO, such as 99 percent of events published within five seconds, so the standard has an owner.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Cloud documentation, Resilience4j documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Several teams in your organisation have independently introduced distributed transaction...": https://scrivio-interview-library.netlify.app/spring-boot/distributed-data/e9948a482a/