Quick revision
The short answer
We treat it as a breaking change and use expand and contract: first add firstName, lastName and a new money field alongside the old fields, keeping customerName and amount populated, so all eight consumers keep working. Consumers move to the new fields at their own pace as tolerant readers, we track who has migrated, and only after an agreed deprecation period do we stop sending the old fields. The amount type cannot change in place, so it gets a new field name or a new event version, and compatibility checks in CI or the schema registry stop anyone from breaking it by accident.
What to remember
In this answer, we rolled out two breaking changes to OrderPlaced without breaking any of its eight consumers. We expanded the event by adding firstName, lastName and a new money field beside the old fields, which stayed populated. Consumers migrated at their own pace as tolerant readers with fallbacks for old events, we tracked migration and removed the old fields only after an agreed deprecation period, and we enforced compatibility in CI or the schema registry so an in-place type change cannot be published again.
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.
We treat it as a breaking change and use expand and contract: first add firstName, lastName and a new money field alongside the old fields, keeping customerName and amount populated, so all eight consumers keep working. Consumers move to the new fields at their own pace as tolerant readers, we track who has migrated, and only after an agreed deprecation period do we stop sending the old fields. The amount type cannot change in place, so it gets a new field name or a new event version, and compatibility checks in CI or the schema registry stop anyone from breaking it by accident.
Why this question is asked
Changing a shared event is like changing a public API with eight clients you cannot deploy yourself. If we change OrderPlaced in place, some of the eight services will fail to parse it on the next deployment, and their consumers will stall or fill the dead-letter topic. Interviewers ask this scenario to see whether we can sequence a change so nothing breaks at any moment. In this answer, we will see exactly why both changes break consumers, design the expanded event, walk through the rollout in phases, handle the amount type change, and cover how to track migration and enforce compatibility.
1Why Both Changes Break Consumers
Today OrderPlaced looks like this: orderId, customerName as one string, and amount as a number. Splitting customerName into firstName and lastName is a rename plus a split: any consumer reading customerName gets null the moment we stop sending it. Changing amount from 4200 to an object with value and currency is a type change: a consumer whose class has long amount fails to parse the whole event with a Jackson MismatchedInputException, so it cannot process the order at all.
The type change is the more dangerous of the two, because it does not just lose a field, it makes the entire message unreadable for old consumers. A single deployment of the producer would stop all eight consumers at once.
2Expand the Event
The first release of the producer only adds. It keeps customerName and amount exactly as they are and adds firstName, lastName and a new field for the money object. Because amount must keep its old type for old consumers, the object needs a different name, here total.
Notice that every old consumer still finds the fields it reads, with the same types, and ignores the new ones, provided it is a tolerant reader that does not fail on unknown fields. Before releasing, we confirm that all eight consumers are tolerant; one that uses a strict mapper must be fixed first, or the expand step itself breaks it.
We also decide how to fill the new fields for old data. Splitting 'Ana Silva' is easy, but names like 'Maria de la Cruz' are not, so the producer should take firstName and lastName from the source, the customer record, rather than splitting the string.
3Consumers Migrate at Their Own Pace
Each consumer team now changes its code to read the new fields, firstName, lastName and total, while still tolerating events that lack them, such as old events replayed from the topic. A consumer that moves to the new fields first and finds them missing in an old event falls back to the old fields.
7 messages in order. Play them, or step through them one at a time.
Nobody breaks at any point, because the old fields stay until everyone has moved.
Consumers deploy whenever they are ready, in any order. Nothing forces them to coordinate with the producer or with each other, which is the whole point of the approach.
4Handling the Type Change: New Field or New Version
There are two ways to deal with amount. The one we used, adding total beside amount, keeps one event type and one topic, and works well when the change is small. Its cost is that the event carries both fields during the deprecation period and the old name, amount, can never be reused with the new type in this event.
The alternative is a new event version, OrderPlacedV2, or a new topic orders.v2, published in parallel with the old one. That is cleaner when many fields change at once, but every consumer must switch topics, and the producer must publish both versions, often through the same outbox, until the old one is retired. For our two changes, adding fields is enough; if we were also restructuring lines and addresses, I would publish a new version.
5Tracking Migration and Removing Old Fields
We keep a list of the eight consumers and their status, ideally from consumer discovery in the event catalogue rather than memory, and agree a deprecation date, for example three months. Each team marks itself migrated when its new code is deployed. We can also verify it: consumers report the schema version they read, or we check consumer code for references to customerName and amount.
When all eight have moved and the date has passed, a producer release stops populating customerName and amount. For long-retention or replayed topics, consumers must keep their fallback code as long as old events remain, which is a reason to record the decision and the date.
6Enforcing Compatibility in CI or the Registry
Finally, we stop this from depending on care alone. If events are described by a schema, JSON Schema, Avro or Protobuf in a schema registry, the registry checks each new version against the compatibility mode, for example BACKWARD or FULL, and rejects one that removes or retypes a field. Without a registry, a CI test can compare the new event schema with the published one and fail the build on breaking changes.
With that check in place, the original plan, change amount to an object in place, would have been rejected in the producer's pull request, before any consumer saw it.
7Follow-up questions
What if one of the eight teams never migrates?
We find out early, because migration is tracked. We talk to the team and offer help; if it is a dormant service, we may make the change for them. We do not remove the old fields while a known consumer still depends on them, but we also do not extend the deadline indefinitely, and escalation through the event owners' agreement is the last step.
Why not let consumers handle both shapes of amount with a custom deserializer?
It is possible, but every consumer must implement it correctly, including services in other languages, and the same field name now means two types depending on the event's age. A new field name keeps each field's type stable and the consumer code obvious.
Do we need schemaVersion in the event?
It is not strictly required for additive changes, but it helps consumers and operators tell which shape they are looking at, it makes metrics on migration easy, and it is useful when replaying old events. It costs one small field.
8Conclusion
In this answer, we rolled out two breaking changes to OrderPlaced without breaking any of its eight consumers. We expanded the event by adding firstName, lastName and a new money field beside the old fields, which stayed populated. Consumers migrated at their own pace as tolerant readers with fallbacks for old events, we tracked migration and removed the old fields only after an agreed deprecation period, and we enforced compatibility in CI or the schema registry so an in-place type change cannot be published again.
Open with
Both changes are breaking. Removing customerName breaks anyone reading it, and changing amount from a number to an object is worse, because old consumers cannot even parse the event.
Then, if they want more
So I would use expand and contract. In the first producer release I add firstName and lastName, filled from the customer record rather than splitting the string, and a new money object under a different name, say total, while customerName and amount stay exactly as they are. Before that release I check that all eight consumers ignore unknown fields.
Then each consumer team migrates when it is ready, reading the new fields with a fallback to the old ones for old or replayed events. I track migration per consumer, ideally from the event catalogue, and agree a deprecation date. Only when all eight have moved and the date has passed do we stop sending the old fields.
If many fields changed at once I would publish a new event version or topic in parallel instead. And to stop this happening again, I would put the schema in a registry or a CI check that rejects removals and type changes, so an in-place change fails in the pull request.
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
- Apache Kafka documentation, Spring for Apache Kafka reference
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 "You need to change a published OrderPlaced event: split "customerName" into "firstName"...": https://scrivio-interview-library.netlify.app/spring-boot/event-driven-patterns/35a8ba5623/