The java code for serializing and deserializing data without generating the code for schema is given below:
For generating the schema java code from Avro json schema we can use avro-tools jar. The command for same is given below:
java -jar avro-tools-1.7.5.jar compile schema StudentActivity.avsc <output_path>Output path can be source folder for the project or we can add the generated java class files to Eclipse IDE manually.
The java code for serializing and deserializing data with generating the code for schema is similar to above code except that in previous code we were assiging values to a GenericRecord and in this one we are assigning values to the generated Avro object:
In next post we will see how Avro deals with schema evolution.