poniedziałek, 12 grudnia 2016

Schema registry and topic with multiple message types

As a continuation of my friend’s great post about schema evolution, I would like to focus now on combining schema evolution (via Schema Registry) for a topic with multiple message types. We know that currently, Schema Registry doesn’t support multiple schemas. Ok, maybe I’m not precise, it supports multiple schemas, but without any backward/forward compatibility checks. This is useless because I would like to manage schema compatibility for particular messages.

Fortunately, Apache Avro provides something called unions. If you don’t fully understand the documentation from the link, don’t worry - it will be clear if you see some basic example. Let’s say we want to produce Email, Sms and PushNotification message for a single topic. Now we need to wrap those message in a single message e.g. MessageToSend.
public class MessageToSend {
  String type;
  String correlationId;
  Object payload;