Author: buildbot
Date: Tue Aug 20 04:34:26 2013
New Revision: 875415

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/avro.html
    websites/production/camel/content/cache/main.pageCache

Modified: websites/production/camel/content/avro.html
==============================================================================
--- websites/production/camel/content/avro.html (original)
+++ websites/production/camel/content/avro.html Tue Aug 20 04:34:26 2013
@@ -86,6 +86,7 @@
         <tr>
         <td valign="top" width="100%">
 <div class="wiki-content maincontent"><h2><a shape="rect" 
name="avro-AvroComponent"></a>Avro Component</h2>
+
 <p><b>Available as of Camel 2.10</b></p>
 
 <p>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.</p>
@@ -103,7 +104,8 @@
 </div></div>
 
 <h3><a shape="rect" name="avro-ApacheAvroOverview"></a>Apache Avro 
Overview</h3>
-<p>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. 
However, it doesn't enforce a schema first approach and you can create schema 
for your existing classes. An example of how a schema looks like is below.</p>
+
+<p>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.</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
 <script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[
@@ -139,7 +141,28 @@
 
 <p>You can easily generate classes from a schema, using maven, ant etc. More 
details can be found at the <a shape="rect" class="external-link" 
href="http://avro.apache.org/docs/current/";>Apache Avro documentation</a>.</p>
 
+<p>However, it doesn't enforce a schema first approach and you can create 
schema for your existing classes. <b>Since 2.12</b> 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:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[
+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; }
+}
+]]></script>
+</div></div>
+<p><em>Note: Existing classes can be used only for RPC (see below), not in 
data format.</em></p>
+
 <h3><a shape="rect" name="avro-UsingtheAvrodataformat"></a>Using the Avro data 
format</h3>
+
 <p>Using the avro data format is as easy as specifying that the class that you 
want to marshal or unmarshal in your route.</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
@@ -171,36 +194,46 @@
         &lt;/route&gt;
     &lt;/camelContext&gt;
 ]]></script>
-</div></div>  
-
+</div></div>
 <p>In the same manner you can umarshal using the avro data format.</p>
 
 <h3><a shape="rect" name="avro-UsingAvroRPCinCamel"></a>Using Avro RPC in 
Camel</h3>
+
 <p>As mentioned above Avro also provides RPC support over multiple transports 
such as http and netty. Camel provides consumers and producers for these two 
transports.</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
 <script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[
 avro:[transport]:[host]:[port]
 ]]></script>
-</div></div> 
-
+</div></div>
 <p>The supported transport values are currently http or netty.</p>
 
-<p>When using camel producers for avro ipc, the "in" message body needs to 
contain the arguments of the operation sepcified in the avro protocol. The 
response will be added in the body of the "out" message.</p>
+<p><b>Since 2.12</b> you can specify message name right in the URI:</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<script class="theme: Default; brush: java; gutter: false" 
type="syntaxhighlighter"><![CDATA[
+avro:[transport]:[host]:[port][/messageName]
+]]></script>
+</div></div>
+
+<p>For consumers this allows you to have multiple routes attach to the same 
socket. Dispatching to correct route will be done by the avro component 
automatically. Route with no messageName specified (if any) will be used as 
default. </p>
+
+<p>When using camel producers for avro ipc, the "in" message body needs to 
contain the parameters of the operation specified in the avro protocol. The 
response will be added in the body of the "out" message.</p>
 
-<p>In a similar manner when using camel avro consumers for avro ipc, the 
requests arguments will be placed inside the "in" message body of the created 
exchange and once the exchange is processed the body of the "out" message will 
be send as a response.</p>
+<p>In a similar manner when using camel avro consumers for avro ipc, the 
requests parameters will be placed inside the "in" message body of the created 
exchange and once the exchange is processed the body of the "out" message will 
be send as a response.</p>
+
+<p><b>Note:</b> By default consumer parameters are wrapped into array. If 
you've got only one parameter, <b>since 2.12</b> you can use 
<tt>singleParameter</tt> URI option to receive it direcly in the "in" message 
body without array wrapping.</p>
 
 <h3><a shape="rect" name="avro-AvroRPCURIOptions"></a>Avro RPC URI Options</h3>
 
 <div class="confluenceTableSmall"><div class="table-wrap">
-<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"> Name </th><th colspan="1" rowspan="1" 
class="confluenceTh"> Description </th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"> <tt>protocolClassName</tt> </td><td colspan="1" 
rowspan="1" class="confluenceTd"> The class name of the avro protocol. 
</td></tr></tbody></table>
+<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"> Name </th><th colspan="1" rowspan="1" 
class="confluenceTh"> Version </th><th colspan="1" rowspan="1" 
class="confluenceTh"> Description </th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"> <tt>protocolClassName</tt> </td><td colspan="1" 
rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" 
class="confluenceTd"> The class name of the avro protocol. </td></tr><tr><td 
colspan="1" rowspan="1" class="confluenceTd"> <tt>singleParameter</tt> </td><td 
colspan="1" rowspan="1" class="confluenceTd"> 2.12 </td><td colspan="1" 
rowspan="1" class="confluenceTd"> If true, consumer parameter won't be wrapped 
into array. Will fail if protocol specifies more then 1 parameter for the 
message </td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"> 
<tt>protocol</tt> </td><td colspan="1" rowspan="1" 
class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" 
class="confluenceTd">
  Avro procol object. Can be used instead of <tt>protocolClassName</tt> when 
complex protocol needs to be created. One cane used #name notation to refer 
beans from the Registry </td></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"> <tt>reflectionProtocol</tt> </td><td colspan="1" 
rowspan="1" class="confluenceTd"> 2.12 </td><td colspan="1" rowspan="1" 
class="confluenceTd"> If protocol object provided is reflection protocol. 
Should be used only with <tt>protocol</tt> parameter because for 
<tt>protocolClassName</tt> protocol type will be autodetected 
</td></tr></tbody></table>
 </div>
 </div>
 
 <h3><a shape="rect" name="avro-AvroRPCHeaders"></a>Avro RPC Headers</h3>
 
 <div class="confluenceTableSmall"><div class="table-wrap">
-<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"> Name </th><th colspan="1" rowspan="1" 
class="confluenceTh">  Description </th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"> <tt>CamelAvroMessageName</tt> </td><td colspan="1" 
rowspan="1" class="confluenceTd"> The name of the message to send. 
</td></tr></tbody></table>
+<table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" 
class="confluenceTh"> Name </th><th colspan="1" rowspan="1" 
class="confluenceTh"> Description </th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"> <tt>CamelAvroMessageName</tt> </td><td colspan="1" 
rowspan="1" class="confluenceTd"> The name of the message to send. In consumer 
overrides message name from URI (if any)</td></tr></tbody></table>
 </div>
 </div>
 
@@ -219,6 +252,17 @@ avro:[transport]:[host]:[port]
 ]]></script>
 </div></div>
 
+<p>In the example above you need to fill <tt>CamelAvroMessageName</tt> header. 
<b>Since 2.12</b> you can use following syntax to call constant messages:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[
+        &lt;route&gt;
+            &lt;from uri="direct:start"/&gt;
+            &lt;to 
uri="avro:http:localhost:{{avroport}}/put?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol"/&gt;
+            &lt;to uri="log:avro"/&gt;
+        &lt;/route&gt;
+]]></script>
+</div></div>
 <p>An example of consuming messages using camel avro consumers via netty:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
@@ -237,7 +281,24 @@ avro:[transport]:[host]:[port]
             &lt;/choice&gt;
         &lt;/route&gt;
 ]]></script>
-</div></div></div>
+</div></div>
+
+<p><b>Since 2.12</b> you can set up two distinct routes to perform the same 
task:</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
+<script class="theme: Default; brush: xml; gutter: false" 
type="syntaxhighlighter"><![CDATA[
+        &lt;route&gt;
+            &lt;from 
uri="avro:netty:localhost:{{avroport}}/put?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol"&gt;
+            &lt;process ref="putProcessor"/&gt;
+        &lt;/route&gt;
+        &lt;route&gt;
+            &lt;from 
uri="avro:netty:localhost:{{avroport}}/get?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol&amp;singleParameter=true"/&gt;
+            &lt;process ref="getProcessor"/&gt;
+        &lt;/route&gt;
+]]></script>
+</div></div>
+
+<p>In the example above, get takes only one parameter, so 
<tt>singleParameter</tt> is used and <tt>getProcessor</tt> will receive Value 
class directly in body, while <tt>putProcessor</tt> will receive an array of 
size 2 with String key and Value value filled as array contents.</p></div>
         </td>
         <td valign="top">
           <div class="navigation">

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.


Reply via email to