yifei
yifei

Reputation: 601

How to enforce Kafka consumer to use certain version of schema?

We have multiple versions of schemas of a topic, and messages are in AVRO format.

From what I understand, when a consumer receives an AVRO message, the message itself contains an id which will be used to retrieve schema from schema registry, and cached locally for future ref.

I am curious to know if there's a way to by-pass this id lookup, and always use one pre-obtained schema (e.g. latest one) to parse all messages on consumer side?

The deserializer we use is io.confluent.kafka.serializers.KafkaAvroDeserializer

Upvotes: 2

Views: 2894

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191963

use.latest.version=true is one config option for the serializer, but there's no setting to use a specific version; the only way I can think of would be to consume using ByteArrayDeserializer, then manually modify the ID, then pass that result into the KafkaAvroDeserializer to get the record with that specific schema ID

Upvotes: 1

Related Questions