Recreating AVRO from separate schema and AVRO binary data files

Viewed 320

I have a scenario where I am receiving data from Kafka that only contains the binary data of AVRO. All the schema and metadata are stripped out before putting the AVRO into the Kafka topics. This is done on purpose to reduce the size of incoming messages.

On the receiving end, I have a schema that should be compatible with that binary data. I have looked into a few examples where SpecificDatumReader classes are used to read AVRO data that have schema and metadata attached to it.

Is it possible in some way to achieve what I am doing by using the parsers libraries?

To provide more insight to what I am asking, I am able to pass in the fragment file with the schema I have and have been able to parse out the data from the binary fragment as JSON using the avro-tools

java -jar avro-tools-1.7.7.jar fragtojson --schema-file mySchema.avsc fragmentFile

So, All I need now is a way to use the avro libraries to stitch the schema and the fragment file together and spit out a valid .avro file.

0 Answers
Related