Producing an event

An object would be sent to Kafka once an event is produced. Similarly, Kafka would send this produced object to all listeners (microservices). In short, the produced object travels over the network. Therefore, we need serialization support for these objects. We'll make use of Apache Avro for data serialization. It defines the data structure (schema) in the JSON format and also provides a plugin for both Maven and Gradle to generate Java classes using JSON schema. Avro works well with Kafka because both Avro and Kafka are Apache products and align well with each other for integration.

Let's start with defining the schema that represents the object sent over the network when a new booking is created. As shared earlier for ...

Get Mastering Microservices with Java 9 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.