Rohan Goyal
Rohan Goyal

Reputation: 31

Different Namespaces for Producer and Consumer Avro Schemas

Schema at producer side:

{
  "type":"record",
  "name":"ClientIdentifier",
  "namespace":"namespace1",
  "fields":[
    {
      "name":"data",
      "type":"string"
    }
  ]
}

Schema at consumer side:

{
  "type":"record",
  "name":"ClientIdentifier",
  "namespace":"namespace2",
  "fields":[
    {
      "name":"data",
      "type":"string"
    }
  ]
}

Both have different namespaces. How to make them compatible with each other.
I am using encoders and decoders present within generated avro classes for serialization and deserialization.


Also, I am using @KafkaListener annotation in consumer in spring boot.

Upvotes: 1

Views: 1307

Answers (1)

Rohan Goyal
Rohan Goyal

Reputation: 31

I found that on using the encoder within the Avro Generated Message, we can not decode back if we have a different namespace at the consumer side since it utilizes namespace's value internally. The only option is to use GenericDatumWriter on the producer side and GenericDatumReader on the consumer side.

Upvotes: 1

Related Questions