You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2016/08/23 11:47:45 UTC
camel git commit: Added Avro Dataformat to Gitbook
Repository: camel
Updated Branches:
refs/heads/master af50946b7 -> 1aa62f89e
Added Avro Dataformat to Gitbook
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1aa62f89
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1aa62f89
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1aa62f89
Branch: refs/heads/master
Commit: 1aa62f89e968c3c504ae69b8ba7d25a658c16b03
Parents: af50946
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Aug 23 13:46:17 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Aug 23 13:46:17 2016 +0200
----------------------------------------------------------------------
.../src/main/docs/avro-dataformat.adoc | 152 +++++++++++++++++++
1 file changed, 152 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/1aa62f89/components/camel-avro/src/main/docs/avro-dataformat.adoc
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/main/docs/avro-dataformat.adoc b/components/camel-avro/src/main/docs/avro-dataformat.adoc
new file mode 100644
index 0000000..f474baf
--- /dev/null
+++ b/components/camel-avro/src/main/docs/avro-dataformat.adoc
@@ -0,0 +1,152 @@
+[[avro-AvroDataformat]]
+Avro Dataformat
+~~~~~~~~~~~~~~~
+
+*Available as of Camel 2.10*
+
+This component provides a dataformat for avro, which allows
+serialization and deserialization of messages using Apache Avro's binary
+dataformat. Moreover, it provides support for Apache Avro's rpc, by
+providing producers and consumers endpoint for using avro over netty or
+http.
+
+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>
+------------------------------------------------------------
+
+[[avro-ApacheAvroOverview]]
+Apache Avro Overview
+^^^^^^^^^^^^^^^^^^^^
+
+Avro allows you to define message types and a protocol using a json like
+format and then generate java code for the specified types and messages.
+An example of how a schema looks like is below.
+
+[source,xml]
+------------------------------------------------------------------------------------------
+{"namespace": "org.apache.camel.avro.generated",
+ "protocol": "KeyValueProtocol",
+
+ "types": [
+ {"name": "Key", "type": "record",
+ "fields": [
+ {"name": "key", "type": "string"}
+ ]
+ },
+ {"name": "Value", "type": "record",
+ "fields": [
+ {"name": "value", "type": "string"}
+ ]
+ }
+ ],
+
+ "messages": {
+ "put": {
+ "request": [{"name": "key", "type": "Key"}, {"name": "value", "type": "Value"} ],
+ "response": "null"
+ },
+ "get": {
+ "request": [{"name": "key", "type": "Key"}],
+ "response": "Value"
+ }
+ }
+}
+------------------------------------------------------------------------------------------
+
+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].
+
+However, it doesn't enforce a schema first approach and you can create
+schema for your existing classes. *Since 2.12* you can use existing
+protocol interfaces to make RCP calls. You should use interface for the
+protocol itself and POJO beans or primitive/String classes for parameter
+and result types. Here is an example of the class that corresponds to
+schema above:
+
+[source,java]
+--------------------------------------------------------------
+package org.apache.camel.avro.reflection;
+
+public interface KeyValueProtocol {
+ void put(String key, Value value);
+ Value get(String key);
+}
+
+class Value {
+ private String value;
+ public String getValue() { return value; }
+ public void setValue(String value) { this.value = value; }
+}
+--------------------------------------------------------------
+
+_Note: Existing classes can be used only for RPC (see below), not in
+data format._
+
+[[avro-UsingtheAvrodataformat]]
+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 ref="avro"/>
+ <to uri="log:out"/>
+ </route>
+ </camelContext>
+--------------------------------------------------------------------------------------
+
+In the same manner you can umarshal using the avro data format.
+
+
+[[avro-AvroDataformat-options]]
+Avro Dataformat Options
+^^^^^^^^^^^^^^^^^^^^^^^
+
+// dataformat options: START
+The Avro dataformat supports 1 options which are listed below.
+
+
+
+{% raw %}
+[width="100%",cols="2s,1m,1m,6",options="header"]
+|=======================================================================
+| Name | Default | Java Type | Description
+| instanceClassName | | String | Class name to use for marshal and unmarshalling
+|=======================================================================
+{% endraw %}
+// dataformat options: END
+