In all Kafka and Kafka Streams programs, many operation involves shuffling data on the network, or storing data in Kafka topics. The data involved must be serializable and for this we need to provide Serdes.

Simple Sagas provides some help to reduce the amount of boilerplate code involved for creating Avro and Json serdes.

Saga Action Command Type

Sagas consist of one free type, the type A in SagaApp<A>.

This is a common representation of an action command, required by the action processor to execute the action.

Due to limitations of the Java type system, it is not possible (or at least not practical) to represent a saga in a serializable format in which each action command has its own specific type.

A compromise needed to be made, and this involves choosing a serializable type that can be conveniently converted to any of the specific types that the action processors are implemented in terms of.


In Simple Sagas, Avro is the recommended serialization format. For Avro serialization an appropriate choice for A is SpecificRecord or GenericRecord.

Helpers are provided to minimise the effort involves with working with these types.

When using Avro serialization, Simple Sagas takes advantage of the Confluent Schema registry to ensure that data conforms to a schema. At runtime, an instance of the Schema registry must be available.

For Java applications, it makes sense to define the domain types in your application as AVDL types, and use the Avro Maven plugin to generate Java classes for these types. These classes implement the SpecificRecord interface, are serializable, and can be used in Sagas easily:

The AvroSerdes.Specific interface provides factory methods for Serdes for any type that implements SpecificRecord.

If it is not possible or desired to represent the domain types with AVDL types, one can use the AvroSerdes methods to create the required Serdes. In this case the user must provide an Serde implementation for the type A.