Quick revision
The short answer
Inconsistent order states come from six services each deciding for themselves what state an order is in. Aligning them means naming one service as the owner of the order lifecycle and its transition rules, having that owner publish order state change events that the other services consume instead of computing state themselves, and documenting the transition table as a shared contract. Contract tests and reconciliation jobs detect mismatches, the services migrate one at a time and delete their local transition logic, and the whole plan is agreed with every owning team and tracked to the end.
What to remember
In this answer, we saw that inconsistent order states come from six services each computing status on their own. We named one service as owner of the lifecycle and its transition rules, had it publish versioned state change events through an outbox for others to consume, documented the transition table as a contract with contract tests, and added reconciliation to detect mismatches. Services migrate one by one and delete their local logic, under a plan agreed with all owning teams and tracked to completion.
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.
Inconsistent order states come from six services each deciding for themselves what state an order is in. Aligning them means naming one service as the owner of the order lifecycle and its transition rules, having that owner publish order state change events that the other services consume instead of computing state themselves, and documenting the transition table as a shared contract. Contract tests and reconciliation jobs detect mismatches, the services migrate one at a time and delete their local transition logic, and the whole plan is agreed with every owning team and tracked to the end.
Why this question is asked
When six services disagree about whether order 5521 is shipped or cancelled, customers see one status on the website and another in the email, support cannot trust any screen, and finance reconciles by hand at month end. The technical cause is duplicated state logic, but the reason it persists is organisational: each team built what it needed, and nobody owns the whole. Interviewers ask this of senior leaders because fixing it needs both a sound technical model and the ability to bring six teams along without stopping their roadmaps. In this answer, we will diagnose why the states diverge, choose an owner, turn the owner's state changes into events, make the transition table a contract, detect mismatches, and lead the migration.
1Why the States Diverge
The first step is understanding the current situation, so we map it. For each of the six services, we find where it stores order status, what events or calls change it, and what rules it applies. Typically we find that checkout, payments, fulfilment, customer service, notifications and finance each keep their own status column and each move it based on what they observe: payments marks an order PAID when the card is captured, fulfilment marks it SHIPPED when the label is printed, and customer service lets agents set CANCELLED directly.
Divergence follows naturally. Each service sees a different subset of events, in a different order, with different rules. If fulfilment ships an order after customer service cancelled it, each believes its own state. A sample of real mismatches, say 1.8 percent of last month's orders disagree somewhere, with the main patterns listed, makes the problem concrete for everyone and gives us a baseline to measure against.
2Naming One Owner of the Lifecycle
The core principle is that one service owns the order lifecycle: it holds the authoritative status, it alone decides whether a transition is allowed, and every other service asks it or listens to it rather than deciding. The natural owner is usually the order service that created the order, or whichever team is closest to the order as a whole, not the payment or shipping specialist. Other services keep their own state about their own concern, such as payment state or shipment state, but they stop keeping their own order status.
Other services now request transitions instead of applying them. Fulfilment does not set SHIPPED; it reports that the shipment left the warehouse, and the owner applies the transition if the table allows it. If the order was cancelled first, the owner rejects the move, and fulfilment gets a clear answer and can start a return to stock.
7 messages in order. Play them, or step through them one at a time.
3Events From the Owner, Not State Computed Everywhere
The owner publishes an OrderStateChanged event for every transition, containing the order id, the previous and new state, a version number that increases with each change, and the time. It publishes through a transactional outbox, so the event is sent if and only if the state change committed. Other services consume these events and keep a read-only copy of the order status if they need one, for display or for their own rules.
The version number matters. Events can arrive late or be delivered twice, so a consumer ignores any event whose version is not newer than the one it already has. That rule alone removes a whole class of mismatches in which an old event overwrote a newer state. Consumers are also built to be idempotent, so a redelivered event changes nothing.
4The Transition Table as a Shared Contract
The owner documents its transition table, every state, every allowed move, and which event or command causes it, and publishes it as a contract alongside the event schema in the schema registry or API documentation. Other teams can rely on it: a notifications service knows that CANCELLED is final, and a finance service knows that REFUNDED only follows CANCELLED or RETURNED. Changes to the table go through the same review as an API change, with notice to consuming teams, because adding a state can break a consumer's switch statement.
Contract tests turn the document into checks. The owner's tests verify that its implementation matches the published table, and consumer-driven contract tests, with a tool such as Spring Cloud Contract or Pact, let each consumer state which events and fields it depends on, so the owner learns before a release if a change would break someone.
| Service | Before | After |
|---|---|---|
| Order service | One of six status columns | Owns status and transition table |
| Payments | Sets PAID itself | Reports PaymentCaptured; keeps payment state |
| Fulfilment | Sets SHIPPED itself | Reports ShipmentDispatched; keeps shipment state |
| Customer service | Agents set CANCELLED | Calls the owner's cancel API |
| Notifications, finance | Infer status from events | Consume OrderStateChanged, read-only copy |
5Detecting Mismatches
Even with one owner, bugs, outages and missed events happen, so we build detection rather than assume correctness. A reconciliation job compares each service's copy of the status with the owner's, nightly at first and later continuously over recent orders, and reports mismatches by service and pattern. During migration it is the main progress measure: the mismatch rate should fall from 1.8 percent towards zero as each service moves. After migration, a mismatch is an alert, and the fix is usually to replay the owner's latest event to the lagging consumer.
6Leading the Migration
The plan only works if the six teams agree to it, so the first deliverable is not code but a short proposal: the mismatch data, the cost in support tickets and refunds, the target model, and what each team must change. We review it with each team's lead and product owner, adjust it where they see problems, and get it onto their roadmaps with an agreed timeline, with sponsorship from whoever owns the customer experience across these teams.
Then we migrate one service at a time, starting with the one that causes the most mismatches or the one most eager to move, to prove the pattern. For each service, it first consumes the owner's events in parallel with its own logic, the reconciliation job shows the two agree, it switches to the owner's state, and finally it deletes its local transition logic, which is the step that makes the change permanent. A simple tracker, visible to all teams, shows each service's stage and the overall mismatch rate, and we review it in a short regular meeting until the last service is done.
- Map its current status logicWhere it stores and changes status
- Consume owner events in parallelShadow copy next to its own status
- Do reconciliation results agree?Mismatch rate for this serviceYesSwitch reads to the owner's stateNoFix event handling or table gaps
- Request transitions from the ownerReplace local updates with commands
- Delete local transition logicTrack as done for all teams
5 steps in order. Play them, or step through them one at a time.
7Follow-up questions
What if a team refuses to give up its own status logic?
We first find out why, because there is often a real need, such as a state the owner does not model yet. The answer is usually to add that state to the shared table or to let the team keep state about its own concern under a different name. If disagreement remains, the mismatch data and the business sponsor decide, but that should be rare when the proposal reflects each team's needs.
Should the owner be a new service built for this?
Usually not. Creating a new service adds a migration of its own; the existing order service, extended with a clear transition table and outbox, is normally the fastest path. A new service makes sense only if no existing one can take the responsibility cleanly.
How do you handle orders that are already inconsistent?
Before the switch for each service, we run a one-time reconciliation and correct historical mismatches, using the owner's state plus evidence such as shipment records where the owner was wrong. Corrections are logged, and finance reviews any that affect money.
8Conclusion
In this answer, we saw that inconsistent order states come from six services each computing status on their own. We named one service as owner of the lifecycle and its transition rules, had it publish versioned state change events through an outbox for others to consume, documented the transition table as a contract with contract tests, and added reconciliation to detect mismatches. Services migrate one by one and delete their local logic, under a plan agreed with all owning teams and tracked to completion.
Open with
I would start by measuring and mapping the problem: where each of the six services stores order status, what changes it, and how often they disagree, for example a percentage of last month's orders, with the main patterns and what they cost in support tickets and refunds.
Then, if they want more
The root cause is that each service computes the order's state from its own partial view. The fix is a single owner. I would name one service, normally the existing order service, as owner of the order lifecycle and its transition rules. Other services stop setting order status.
Fulfilment reports that a shipment left, payments reports a capture, customer service calls the owner's cancel API, and the owner decides whether the transition is allowed. The owner publishes OrderStateChanged events through an outbox, with a version number so consumers can ignore stale or duplicate events, and consumers keep only a read-only copy.
The transition table becomes a published contract, reviewed like an API, with contract tests so the owner knows if a change breaks a consumer. A reconciliation job compares every service's copy with the owner and reports mismatches, which is both our safety net and our progress metric.
Then the leadership part: I would write a short proposal with the data, review it with each team's lead and product owner, adjust it, and get it on their roadmaps with a sponsor.
We migrate one service at a time, run the new event consumption in parallel until reconciliation agrees, switch, and delete the local logic, tracking every service's stage until all six are done.
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 official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
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 "Six services each implement their own version of the order lifecycle, and orders end up...": https://scrivio-interview-library.netlify.app/java/behavioral-patterns/27b2db918f/