Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

Teams publish fine-grained domain events from inside their services, and other teams have started consuming them directly. Now any internal change breaks consumers. How do you separate internal domain events from integration events?

We separate the two kinds explicitly: internal domain events belong to a service's own model and may change freely, while integration events are public contracts between teams that are stable, versioned, documented and owned. Each service translates the internal events it wants to share into integration events at its boundary, often while writing to the outbox, and keeps them small and focused on the facts consumers need rather than the whole entity. Compatibility is checked on every change with a schema registry or contract tests, and breaking changes come with a new version and a deprecation period for consumers.

Why this question is asked

This problem appears in many organisations a year or two after they adopt events. Publishing events was easy, consuming them was easy, and soon dozens of consumers depended on the exact shape of events that were never meant to leave their service. Now a developer who renames a field in an internal class breaks three other teams' services in production. Interviewers ask this design question to see whether we can restore team independence without stopping the flow of data. In this answer, we will see why internal events leak, define the two kinds of events, translate between them at the boundary, design a good integration event, protect the contract with tooling, and handle breaking changes.

1How Internal Events Became Contracts by Accident

Inside a service, domain events are a modelling tool. A Catalog service might raise ProductPriceAdjusted, ProductDiscountRuleChanged and ProductRecalculated as its pricing logic works through a change. These events follow the internal model: they may contain internal ids, enum values that only make sense inside the service, or the full entity serialised as JSON.

The trouble started when these events were written straight to a shared Kafka topic. Other teams found them useful and subscribed, and from that moment every detail of the internal model was part of a public interface that nobody had designed or agreed to. The producing team does not even know who its consumers are. So an internal refactoring, which should be the team's own business, becomes a cross-team breaking change.

2Two Kinds of Events With Different Rules

The fix starts with naming the difference. Internal domain events are part of the service's private model. They are used between aggregates and modules of one service, they may change in any release, and only the owning team consumes them.

Integration events are public contracts. They are published deliberately for other teams, have a documented schema and meaning, a named owning team, a version, and compatibility rules. They change slowly and on purpose, like a public REST API.

Internal domain events versus integration events
Internal domain eventIntegration event
AudienceThe owning service onlyOther teams and services
StabilityMay change in any releaseStable, versioned, changed deliberately
ShapeFollows the internal modelDesigned for consumers, small
DocumentationCode is enoughSchema, meaning, owner, examples
Where it travelsIn-process or internal topicPublic topic, via the outbox
ExampleProductDiscountRuleChangedProductPriceChanged v2

3Translating at the Service Boundary

Each service translates the internal events it wants to share into integration events at its boundary. The translation is a small, explicit piece of code, owned by the producing team, that turns an internal fact into a public one. A natural place for it is when writing to the transactional outbox, so the public event is stored in the same transaction as the change and reliably published later.

Java
// Internal: free to change
record ProductDiscountRuleChanged(ProductEntityId id, DiscountRule rule, PricingSnapshot snapshot) { }
// Public contract: small and stable
record ProductPriceChangedV2(String eventId, String productSku, String currency,
String newPrice, String effectiveFrom) { }
@Component
class CatalogEventTranslator {
@EventListener // runs inside the transaction that changed the price
void on(ProductDiscountRuleChanged e) {
Money price = e.snapshot().finalPrice();
outbox.add("catalog.product-price-changed", "ProductPriceChanged", 2,
new ProductPriceChangedV2(UUID.randomUUID().toString(), e.snapshot().sku(),
price.currency().getCurrencyCode(), price.amount().toPlainString(), e.snapshot().effectiveFrom().toString()));
}
}
Step throughWhere translation happens
  1. Domain modelraises internal events such as ProductDiscountRuleChanged
  2. Translator at the boundarydecides what is public and maps it
  3. Outboxstores the integration event in the same transaction
  4. Public topicProductPriceChanged v2, schema-checked, documented
  5. Consumers in other teamsdepend only on the public contract

5 layers, from the top down. Step through them one at a time.

Notice that three different internal events may all produce the same public event, because consumers only care that the price changed, not which pricing rule caused it. Internal events that consumers do not need are not published at all. And the internal topic, if there is one, is made private, for example with Kafka ACLs, so nobody can subscribe to it again by accident.

4Designing a Good Integration Event

An integration event should be small and focused on the facts consumers need. That usually means stable identifiers that other teams already know, such as a SKU rather than an internal database id, the values that changed, and when the change takes effect. It should not be the whole internal entity, because every extra field is one more thing we promise never to break.

When consumers need more, there are two good options. They can call the producer's API with the id from the event, or the producer can publish a deliberate state event, such as ProductSnapshot, designed and versioned for that purpose. Either is better than exposing the internal model.

5Protecting the Contract on Every Change

Contracts need automatic checks, because people forget. A schema registry, such as one used with Avro, Protobuf or JSON Schema, stores each version of an event's schema and rejects a new version that breaks the configured compatibility rule, for example backward compatibility, where new consumers can still read old events. Running that check in the producer's build means a breaking change fails before it is merged.

Consumer-driven contract tests add the other side: each consuming team publishes the parts of the event it relies on, and the producer's build verifies that its events still satisfy them, with tools such as Pact or Spring Cloud Contract. Together they turn 'we broke three teams in production' into 'the build failed with a clear message'.

6Handling Breaking Changes With a Deprecation Period

Sometimes a breaking change is necessary. Then the producer publishes the new version alongside the old one, for example ProductPriceChanged v2 on a new topic or with a new type in the header, while still publishing v1. Consumers get a deprecation period, such as three months, announced with the date v1 will stop. The producer tracks which consumer groups still read v1, using Kafka consumer group lag or offsets on the old topic, and contacts them directly. Only when nobody reads v1 does it stop publishing. This costs the producer some extra work, which is right: the team that wants the change pays for it, rather than surprising everyone else.

7Follow-up questions

Should integration events be fat or thin?

Somewhere in between. A thin event with only an id forces every consumer to call back, which adds load and coupling in time. A fat event with the whole entity couples consumers to its structure. Include the facts most consumers need to act on, and no more.

Who owns the integration event schema?

The producing team. It decides the content, versions it and answers questions, much like an API owner. Consumers can request changes, but they do not edit the schema.

What do we do with the existing consumers of internal events?

Inventory them from consumer groups, design integration events that cover their needs, migrate them one by one with a deadline, and then make the internal topic private with access controls.

8Conclusion

In this answer, we separated internal domain events, which belong to a service's own model and may change freely, from integration events, which are stable, versioned, documented and owned public contracts. We translate internal events into integration events at the service boundary, often through the outbox, keep integration events small and focused on what consumers need, check compatibility with a schema registry or contract tests on every change, and give consumers a deprecation period for breaking changes.

What to say in the interviewAbout 100 seconds aloud

Open with

The root cause is that internal events became public contracts by accident. Inside a service, domain events follow the internal model and should be free to change, but once they went to a shared topic and other teams subscribed, every refactoring became a breaking change.

Then, if they want more

So I would make the distinction explicit. Internal domain events stay private to the service, on in-process listeners or an internal topic locked down with access controls. Integration events are designed as public contracts: a documented schema, a named owning team, a version, and compatibility rules, just like a public API.

At the boundary, each service has a small translator, owned by the producing team, that turns the internal events it wants to share into integration events, and writes them to the outbox in the same transaction, so publishing stays reliable. Several internal events can map to one public event, like any pricing rule change becoming ProductPriceChanged.

I keep integration events small, with stable identifiers like a SKU and the facts that changed, not the whole entity. Then I protect the contract with tooling: a schema registry with a compatibility rule checked in the producer's build, and consumer-driven contract tests where useful.

When a breaking change is unavoidable, the producer publishes the new version next to the old one, announces a deprecation period of a few months, tracks which consumer groups still read the old one, and only then switches it off. Existing consumers of internal events get migrated one by one with a deadline.

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 "Teams publish fine-grained domain events from inside their services, and other teams...": https://scrivio-interview-library.netlify.app/java/domain-driven-design/2162a12ee4/