I was trying to implement TopicRecordNameStrategy in Apache Kafka. I have written a producer that will produce the record using this strategy. I used a consumer to just read the record and try to understand how it will work. The schema is registered as per the strategy in schema registry.
Below is the configuration I used in consumer side.
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
props.put(VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class.getName());
props.put(SCHEMA_REGISTRY_URL_CONFIG, "http://localhost:8085/");
props.put(VALUE_SUBJECT_NAME_STRATEGY, TopicRecordNameStrategy.class.getName());
props.put(KEY_SUBJECT_NAME_STRATEGY, TopicRecordNameStrategy.class.getName());
What I saw on the consumer side was there is no specific headers information regarding the schema or strategy used.
My doubts are:
How will the consumer know how to read the records without knowing the subject name and id of the schema?
Will the same consumer read multiple record types, if not what happens when the same consumer read different record types?
EDITS: To the first question, I understand now that the schema id is send as the first five bytes of the data. The schema registry API reference also shows that the API endpoint /schemas/ids/{int: id} can be used to fetch data without subject name or version. But that does that mean that I only need to know schema id in the consumer and the naming strategy and the version id is not required or valid for the consumer?