Now accepting guest editorial from SAP, Oracle, Workday and ServiceNow practitioners.Pitch a guide
The Sign-Off Table

Lesson 4 of 6

Event contracts and versioning

10 min

Listen to this lesson

0:00 / 8:08

An event is an interface, even if nobody calls it one. The producer promises a type, a topic, an envelope and a payload; every consumer builds on that promise. When Kenji's team renamed a field in the custom agreementClosed event, two consumers broke in CMQ, and nobody could say in advance who would be affected. An event contract makes the promise explicit, versioned and testable.

What an event contract contains

PartContoso's agreementClosed v1Where it is defined
Typecmc.o2c.coreagreement.Closed.v1 (CloudEvents type)Contract document; producer code
Topiccmc/o2c/coreagreement/Closed/v1/{companyCode}/{agreement}Topic design (lesson 3)
EnvelopeCloudEvents 1.0: specversion, type, source, id, time, datacontenttypeCloudEvents specification
Payload schemaAgreement number, customer, company code, closing date, deposit totalJSON Schema in an AsyncAPI document
SemanticsSent once per agreement closed, after commit; notification plus key dataContract document
Owner and consumersKenji's team; refund handler, warranty app, analyticsEvent catalog

The parts of an event contract, with Contoso's custom agreement event as the example (illustrative names).

For SAP's standard events, most of this already exists: the SAP Business Accelerator Hub documents S/4HANA business events with their payloads and offers AsyncAPI specifications to download. For custom events, Contoso writes its own AsyncAPI document and stores it with the code. In advanced event mesh, Event Portal serves as the catalog: architects and developers catalog events, schemas and the applications that publish and subscribe to them, so the question "who consumes agreementClosed?" has an answer.

A minimal event catalog model: every event version has one schema and topic pattern, and every application records what it publishes and subscribes to.
The Sign-Off Table · thesignofftable.com/academy/sap-int-206

Compatible and breaking changes

ChangeCompatible?What to do
Add an optional fieldUsually yes, if consumers ignore unknown fieldsSame version; tell consumers; test a tolerant reader
Add a required fieldYes for consumers, if producers always send itSame version if all producers are updated together
Rename or remove a fieldNoNew version (v2); publish v1 and v2 in parallel
Change a field's type or meaningNoNew version, even if the name stays
Change when the event is sentNo (semantic change)New version or new event type
Change the topic hierarchyNo for subscribersNew topic version; dual publish during transition

Rules Theo applies to every event change. A change is breaking if any consumer could behave differently.

The lifecycle of an event version: a breaking change creates a new version; the old one is deprecated and retired only after its last consumer moves.
The Sign-Off Table · thesignofftable.com/academy/sap-int-206

Walkthrough: versioning agreementClosed

  1. The business wants the deposit total split into refunded and retained amounts, replacing one field with two. That is a breaking change.
  2. Kenji's team defines cmc.o2c.coreagreement.Closed.v2 with a new schema and the topic level v2, documents it in AsyncAPI and in the catalog.
  3. The producer publishes both v1 and v2 for every closed agreement during the transition.
  4. Each consumer team moves its subscription from .../Closed/v1/> to .../Closed/v2/> in its own release, after its tests pass on v2.
  5. The catalog shows v1 consumers dropping to zero; Theo announces the v1 end date and then stops publishing v1.

Data events and sensitive data

Most SAP standard events are notifications with keys. Custom events are where teams are tempted to add data: names, addresses, amounts. Every field added to an event is copied to every subscriber's queue and logs, so Nadia, the security and GRC lead, reviews payloads that carry personal or financial data. Contoso's rule is to send keys plus the minimum data consumers cannot reasonably fetch, and to let consumers read the rest through APIs with their own authorizations. The deposit total in agreementClosed passed that review; the customer's contact person did not.

Contract tests

Contract tests catch breaking changes before they reach CMQ. On the producer side, a test builds the event from known agreement data and validates it against the published schema: if the schema says depositTotal is required and a developer renames it, the build fails. On the consumer side, each consumer keeps sample events for every version it supports and runs them through its parser and logic. Contoso stores the samples in the same repository as the AsyncAPI document, so both sides test against one source of truth.

  1. Producer buildEvent built from test data validates against the schema of its version
  2. Consumer buildSample events for each supported version pass parser and logic tests
  3. Catalog reviewBreaking change without a new version is rejected in review
  4. CMQ integrationReal events from CMQ client 100 reach each subscribed consumer
  5. ReleaseCatalog updated: versions, consumers, deprecation dates
Where contract checks run in Contoso's delivery flow.
The Sign-Off Table · thesignofftable.com/academy/sap-int-206

What goes wrong in testing

  • Silent breaking change. A field rename shipped under the same version breaks consumers in production.
  • Strict readers. A consumer that rejects any unknown field turns every compatible change into an outage.
  • No catalog. The producer cannot know who to notify.
  • Forever-dual publishing. v1 is never retired, and every change must be made twice.

What would you do?

Kenji's team wants to rename customer to soldToParty in agreementClosed v1 because "it is only a name". Two consumers read customer today. What should Theo require?

Key points
  • An event contract covers type, topic, envelope, payload schema, semantics, owner and consumers.
  • Use the Business Accelerator Hub for SAP events and AsyncAPI documents for custom events; Event Portal can catalog both.
  • Renames, removals, type or meaning changes are breaking: new version, dual publish, retire.
  • Contract tests on both sides catch breaking changes before CMQ.

Check your understanding · not graded

Lesson check

  1. 1. Which change to an event is breaking?

  2. 2. Where can teams find AsyncAPI documents for S/4HANA business events?

  3. 3. What does dual publishing during a transition mean?

  4. 4. What does a producer-side contract test check?

  5. 5. When can v1 of an event be retired?