Video in progress

You have to make a breaking change in the contract of an event with many consumers. How do you roll it out?

I don't break the old topic in place; I release the new version in parallel (orders.v2 or a new event type), the producer writes both for a while, consumers move at their own pace, and v1 is shut down once the last one has moved. The key is knowing exactly who reads what.

📖 Answer

Example: the amount field was a double (which is a mistake in itself), and now we need amountMinor: long and currency. This breaks compatibility: old consumers can't read the new message.

First I check: is breaking really necessary? Often you can add the new field, mark the old one "deprecated", and fill both for a while. That doesn't break compatibility and is the cheapest way.

If breaking is necessary:

  1. A new contract. A payments.charge.completed.v2 topic with its own schema. You can also mix two versions in one topic (with a type/version header), but that's confusing for consumers and also requires changing the schema registry's subject strategy.

  2. The producer emits both. Two different events from the outbox, or one event and a small stream application that converts it to v1. The second is better: the producer code knows only the new model, and the old format is produced at the edge.

  3. The consumers move. I find out who is reading v1 from the consumer group list. Each team gets a deadline (say, 2 sprints) and a migration guide. When they start reading v2, where to start matters: from the point in time where they stopped in v1, and be ready for duplicates at the crossover.

  4. Removing v1. When no active member is left in the consumer groups, the producer stops writing v1. The topic is kept until retention runs out, then deleted.

What you prepare in advance for such rollouts: a catalog of topics and schemas (who reads), a deprecation policy ("the old version is supported for 3 months") and a communication channel with consumers. Without them, a breaking change becomes an organizational problem, not a technical one: finding the last consumer takes months.