<commit_before>[[avro-dataformat]]
= Avro DataFormat
//THIS FILE IS COPIED: EDIT THE SOURCE FILE:
:page-source: components/camel-avro/src/main/docs/avro-dataformat.adoc
:docTitle: Avro
:artifactId: camel-avro
:description: Serialize and deserialize messages using Apache Avro binary data format.
:since: 2.14
:supportLevel: Stable
include::{cq-version}@camel-quarkus:ROOT:partial$reference/dataformats/avro.adoc[opts=optional]

*Since Camel {since}*

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:

[source,xml]
------------------------------------------------------------
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-avro</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
------------------------------------------------------------


You can easily generate classes from a schema, using maven, ant etc.
More details can be found at the
http://avro.apache.org/docs/current/[Apache Avro documentation].

== Using the Avro data format

Using the avro data format is as easy as specifying that the class that
you want to marshal or unmarshal in your route.

[source,xml]
--------------------------------------------------------------------------------
    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="direct:in"/>
            <marshal>
                <avro instanceClass="org.apache.camel.dataformat.avro.Message"/>
            </marshal>
            <to uri="log:out"/>
        </route>
    </camelContext>
--------------------------------------------------------------------------------

An alternative can be to specify the dataformat inside the context and
reference it from your route.

[source,xml]
--------------------------------------------------------------------------------------
    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
         <dataFormats>
            <avro id="avro" instanceClass="org.apache.camel.dataformat.avro.Message"/>
        </dataFormats>
        <route>
            <from uri="direct:in"/>
            <marshal><custom ref="avro"/></marshal>
            <to uri="log:out"/>
        </route>
    </camelContext>
--------------------------------------------------------------------------------------

In the same manner you can umarshal using the avro data format.


== Avro Dataformat Options

// dataformat options: START
The Avro dataformat supports 1 options, which are listed below.



[width="100%",cols="2s,1m,1m,6",options="header"]
|===
| Name | Default | Java Type | Description
| instanceClassName |  | String | Class name to use for marshal and unmarshalling
|===
// dataformat options: END

include::{page-component-version}@camel-spring-boot::page$avro-starter.adoc[]<commit_msg>CAMEL-16849 - Add at least one example for component in docs - Camel-Avro<commit_after>[[avro-dataformat]]
= Avro DataFormat
//THIS FILE IS COPIED: EDIT THE SOURCE FILE:
:page-source: components/camel-avro/src/main/docs/avro-dataformat.adoc
:docTitle: Avro
:artifactId: camel-avro
:description: Serialize and deserialize messages using Apache Avro binary data format.
:since: 2.14
:supportLevel: Stable
include::{cq-version}@camel-quarkus:ROOT:partial$reference/dataformats/avro.adoc[opts=optional]

*Since Camel {since}*

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:

[source,xml]
------------------------------------------------------------
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-avro</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
------------------------------------------------------------


You can easily generate classes from a schema, using maven, ant etc.
More details can be found at the
http://avro.apache.org/docs/current/[Apache Avro documentation].


== Avro Dataformat Options

// dataformat options: START
The Avro dataformat supports 1 options, which are listed below.



[width="100%",cols="2s,1m,1m,6",options="header"]
|===
| Name | Default | Java Type | Description
| instanceClassName |  | String | Class name to use for marshal and unmarshalling
|===
// dataformat options: END

== Examples

== Avro Data Format usage

Using the avro data format is as easy as specifying that the class that
you want to marshal or unmarshal in your route.

[source,java]
--------------------------------------------------------------------------------
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

[source,xml]
--------------------------------------------------------------------------------
    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="direct:in"/>
            <marshal>
                <avro instanceClass="org.apache.camel.dataformat.avro.Message"/>
            </marshal>
            <to uri="log:out"/>
        </route>
    </camelContext>
--------------------------------------------------------------------------------

An alternative can be to specify the dataformat inside the context and
reference it from your route.

[source,xml]
--------------------------------------------------------------------------------------
    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
         <dataFormats>
            <avro id="avro" instanceClass="org.apache.camel.dataformat.avro.Message"/>
        </dataFormats>
        <route>
            <from uri="direct:in"/>
            <marshal><custom ref="avro"/></marshal>
            <to uri="log:out"/>
        </route>
    </camelContext>
--------------------------------------------------------------------------------------

In the same manner you can umarshal using the avro data format.

include::{page-component-version}@camel-spring-boot::page$avro-starter.adoc[]
{'fraction_non_alphanumeric': 0.25879886176426536, 'fraction_numerical': 0.004642803654335779, 'mean_word_length': 1.9431467606875275, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3868382', 'n_tokens_mistral': 1794, 'n_tokens_neox': 1704, 'n_words': 516}