Contracts for messages
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
apply contracts to Kafka events.
Planned topics
- A message is also an API: the producer must not break consumers' parsing.
- The consumer defines the message shape it reads (
OrderPlacedwithorderId,lines); the producer verifies it can generate it. - Pact message pacts and Spring Cloud Contract messaging both support this; verify the version and the supported broker setups before recording.
- Combine with a schema registry for compatibility rules (see the messaging modules).
Draft outline details
Demonstration
a contract for OrderPlaced: required orderId (string), totalCents (integer); provider test builds the real event and checks it.
Check your understanding
Why test a message contract?
Show answer
Consumers parse fields; renaming one breaks them silently.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.