Chapter 55. Avro
This component provides a dataformat for avro, which allows serialization and deserialization of messages using Apache Avro’s binary dataformat. Since Camel 3.2 rpc functionality was moved into separate camel-avro-rpc
component.
Maven users will need to add the following dependency to their pom.xml
for this component:
You can easily generate classes from a schema, using maven, ant etc. More details can be found at the Apache Avro documentation.
55.1. Avro Dataformat Options Copy linkLink copied to clipboard!
The Avro dataformat supports 1 options, which are listed below.
Name | Default | Java Type | Description |
---|---|---|---|
instanceClassName |
| Class name to use for marshal and unmarshalling. |
55.2. Avro Data Format usage Copy linkLink copied to clipboard!
Using the avro data format is as easy as specifying that the class that you want to marshal or unmarshal in your route.
AvroDataFormat format = new AvroDataFormat(Value.SCHEMA$); from("direct:in").marshal(format).to("direct:marshal"); from("direct:back").unmarshal(format).to("direct:unmarshal");
AvroDataFormat format = new AvroDataFormat(Value.SCHEMA$);
from("direct:in").marshal(format).to("direct:marshal");
from("direct:back").unmarshal(format).to("direct:unmarshal");
Where Value is an Avro Maven Plugin Generated class.
or in XML
An alternative can be to specify the dataformat inside the context and reference it from your route.
In the same manner you can umarshal using the avro data format.
55.3. Spring Boot Auto-Configuration Copy linkLink copied to clipboard!
When using avro with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
The component supports 2 options, which are listed below.
Name | Description | Default | Type |
---|---|---|---|
camel.dataformat.avro.enabled | Whether to enable auto configuration of the avro data format. This is enabled by default. | Boolean | |
camel.dataformat.avro.instance-class-name | Class name to use for marshal and unmarshalling. | String |