Like two communication to find a mutual understanding of the language, in the domestic for Putonghua, running abroad and more in English, two inter-process communication also need to find a data format that everyone can understand. Simple as JSON, XML, which is a self-descriptive format, XML has a schema definition, but there is no formal JSON schema specification. In the efficiency of the occasion, the text-based data interchange format can not meet the requirements, so there are binary Google protobuf and Apache Avro. In the Apache ecosystem like Hadoop, Kafka naturally chooses Avro.
Avro supports multiple languages, such as C, C + +, C #, Java, PHP, Python, and Ruby. It uses JSON to define the schema, which can be used by the schema to generate data objects of the corresponding language, such as Java's Avro-tools.jar. This can be exchanged for objects across the process of cross-language transparent implementations.
The Avro Schema file is the communication protocol of data production and consumption end; We can generate the corresponding Java object from the Schema, and then exchange it with a specific Java object, or simply interact with it without generating a Java object GenericRecord
. For the simplicity of manipulating data, we typically use the previous approach, which is to generate specific data transfer objects. Read the full >> ;
Apache Avro serialization and deserialization (Java implementation)