Avro does not support inheritance but some of the reuse can still be accomplished using composition.
For example, instead of using the same Event
and keep adding mutually exclusive optional fields for BlueEvent
and GreenEvent
,
composition can be used to create two separate events, BlueEvent
and GreenEvent
.
A consumer could then consume either one or both. To register multiple schemas in the schema registry for the same topic, TopicRecordNameStrategy
subject name strategy should be used.
See events, consumer and relevant Kafka configuration attached.