advanced 2 min answer

A team proposes exposing their service's database change stream via CDC so other teams can consume it, avoiding the work of building an event API. What is your assessment?

cdcintegrationcouplingcontracts
Show the full answer Hide the answer

Name what is actually being proposed

The proposal is to publish the service's internal schema as its integration contract. CDC does not emit domain events; it emits row mutations. orders row 4711 status changed from 3 to 7 is a fact about a table, and every consumer must reconstruct business intent from column diffs.

That means each consumer encodes knowledge of the producer's private data model, which the producing team believes is theirs to change.

The consequence, concretely

A routine refactor — splitting a table, renaming a column, changing an enumeration, introducing a soft delete — silently breaks consumers the producing team has never met. They discover it after deployment, from someone else's incident. The database schema has become a published API without anyone deciding that it should be.

The second-order effect is worse: once the team understands this, they stop refactoring. The schema ossifies, and a design constraint that was supposed to be internal becomes permanent.

Where CDC is the right tool

It is genuinely good for two things, and the distinction is worth stating clearly so the answer is not read as a blanket no:

  • Replication into an analytical store. The consumer is a data platform that wants a faithful copy; coupling to the source schema is expected and managed through the platform's own modelling layer.
  • The strangler pattern, where a legacy system cannot be modified to emit events and CDC is the only way to get change out of it. Here it is an explicitly transitional mechanism with an end date.

What to propose instead

A translation layer owned by the producing team. CDC feeds it internally; it publishes domain events with a versioned, documented contract — OrderCancelled, with the fields the business means, not the columns the table has.

The cost is real and should be acknowledged: it is work the team was trying to avoid. The argument for paying it is that the alternative is not zero-cost, it is deferred cost paid by other teams at unpredictable times, plus the permanent loss of the ability to change the schema.

If the transitional route is chosen anyway

Make the coupling explicit rather than implicit. Publish it under a name that says what it is (orders.internal.cdc), state in writing that it carries no compatibility guarantee, register the consumers so the producing team knows who they are, and set a date by which the domain event contract exists. Undocumented coupling is what turns into a five-year constraint; documented coupling with an end date is a managed decision.