Background:
I am working on the Kafka library for the project. When user of the library passes a record to put into Kafka, the library needs to add additional information on top of the user's record.
For Avro typed values in the record, originally I was thinking that the library will define Kafka record's value Avro schema, which will have "headers" field and can be used to add additional information. In addition, it will have another field for user's record value reference.
For example,
KafkaLibraryRecordValueRecord
-> field -> headers
-> field -> KafkaUserRecordValueRecord
Few things I should bring up:
- Library does not know Avro record types of different users' feature models in advance.
- I did not want to ask all users to add "headers" field to the schemas they define for their features. This does not seem user friendly.
Question:
I am very novice in Avro and Schema Registry and am reading up on things. But so far from what I have read, there does not seem to be easy way of doing this.
- First of all, schema registry does not support schema references.
- May be there is a possibility of doing this in a reverse way, where through some Avro code generation customization, during build, headers field can be inserted into each user's schema? I would still have to use reflection in the library code to access the header field from user's Avro object?
Any thoughts on how this can be done?
I went through this discussion, which seems to discuss this issue, but there does not seem to be any concrete solution in the discussion:
https://groups.google.com/forum/#!searchin/confluent-platform/schema$20header%7Csort:relevance/confluent-platform/8xPbjyUE_7E/dyuYxvJ7vC8J