Modified: websites/production/camel/content/netty.html
==============================================================================
--- websites/production/camel/content/netty.html (original)
+++ websites/production/camel/content/netty.html Fri Aug 25 15:19:58 2017
@@ -36,17 +36,6 @@
<![endif]-->
- <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css'
rel='stylesheet' type='text/css' />
- <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css'
rel='stylesheet' type='text/css' />
- <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js'
type='text/javascript'></script>
- <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js'
type='text/javascript'></script>
-
- <script type="text/javascript">
- SyntaxHighlighter.defaults['toolbar'] = false;
- SyntaxHighlighter.all();
- </script>
<title>
Apache Camel: Netty
@@ -86,94 +75,72 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="Netty-NettyComponent">Netty
Component</h2><p><strong>Available as of Camel 2.3</strong></p><div
class="confluence-information-macro confluence-information-macro-warning"><span
class="aui-icon aui-icon-small aui-iconfont-error
confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>This component is deprecated. You
should use <a shape="rect" href="netty4.html">Netty4</a>.</p></div></div><p>The
<strong style="line-height: 1.42857;">netty</strong> component in Camel is a
socket communication component, based on the <a shape="rect"
class="external-link" href="http://netty.io/" rel="nofollow"
style="line-height: 1.42857;">Netty</a> project.</p><p>Netty is a NIO client
server framework which enables quick and easy development of network
applications such as protocol servers and clients.<br clear="none"> Netty
greatly simplifies and streamlines network programming such as TCP and UDP
socket server.</p><p>This
camel component supports both producer and consumer endpoints.</p><p>The
Netty component has several options and allows fine-grained control of a number
of TCP/UDP communication parameters (buffer sizes, keepAlives, tcpNoDelay etc)
and facilitates both In-Only and In-Out communication on a Camel
route.</p><p>Maven users will need to add the following dependency to their
<code>pom.xml</code> for this component:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[<dependency>
+<div class="wiki-content maincontent"><h2 id="Netty-NettyComponent">Netty
Component</h2><p><strong>Available as of Camel
2.3</strong></p><rich-text-body><p>This component is deprecated. You should use
<a shape="rect" href="netty4.html">Netty4</a>.</p></rich-text-body><p>The
<strong style="line-height: 1.42857;">netty</strong> component in Camel is a
socket communication component, based on the <a shape="rect"
class="external-link" href="http://netty.io/" rel="nofollow"
style="line-height: 1.42857;">Netty</a> project.</p><p>Netty is a NIO client
server framework which enables quick and easy development of network
applications such as protocol servers and clients.<br clear="none"> Netty
greatly simplifies and streamlines network programming such as TCP and UDP
socket server.</p><p>This camel component supports both producer and consumer
endpoints.</p><p>The Netty component has several options and allows
fine-grained control of a number of TCP/UDP communication parameters (buffer
sizes
, keepAlives, tcpNoDelay etc) and facilitates both In-Only and In-Out
communication on a Camel route.</p><p>Maven users will need to add the
following dependency to their <code>pom.xml</code> for this
component:</p><parameter
ac:name="">xml</parameter><plain-text-body><dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-netty</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
-]]></script>
-</div></div><h3 id="Netty-URIformat">URI format</h3><p>The URI scheme for a
netty component is as follows</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[netty:tcp://localhost:99999[?options]
+</plain-text-body><h3 id="Netty-URIformat">URI format</h3><p>The URI scheme
for a netty component is as
follows</p><plain-text-body>netty:tcp://localhost:99999[?options]
netty:udp://remotehost:99999/[?options]
-]]></script>
-</div></div><p>This component supports producer and consumer endpoints for
both TCP and UDP.</p><p>You can append query options to the URI in the
following format, <code>?option=value&option=value&...</code></p><h3
id="Netty-Options">Options</h3><div class="confluenceTableSmall"><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>keepAlive</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Setting to ensure socket is not
closed due to inactivity</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>tcpNoDelay</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>
<code>true</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Setting to improve TCP protocol
performance</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>backlog</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.9.6/2.10.4/2.11:</strong> Allows to
configure a backlog for netty consumer (server). Note the backlog is just a
best effort depending on the OS. Setting this option to a value such as
<code>200</code>, <code>500</code> or <code>1000</code>, tells the TCP stack
how long the "accept" queue can be. If this option is not configured, then the
backlog depends on OS setting.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>broadcast</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Setting to choose Multicast over UDP</p>
</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>connectTimeout</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>10000</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Time to wait for a socket connection to be
available. Value is in millis.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>reuseAddress</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Setting to facilitate socket
multiplexing</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>sync</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Setting to set endpoint as one-way or
request-response</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>synchronous</code></p></td><td colspan="1"
rowspan="1" class
="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.10:</strong> Whether <a shape="rect"
href="asynchronous-routing-engine.html">Asynchronous Routing Engine</a> is not
in use. <code>false</code> then the <a shape="rect"
href="asynchronous-routing-engine.html">Asynchronous Routing Engine</a> is
used, <code>true</code> to force processing synchronous.</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>ssl</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Setting to specify whether SSL
encryption is applied to this endpoint</p></td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>sslClientCertHeaders</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong>
When enabled and
in SSL mode, then the Netty consumer will enrich the Camel <a shape="rect"
href="message.html">Message</a> with headers having information about the
client certificate such as subject name, issuer name, serial number, and the
valid date range.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>sendBufferSize</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>65536 bytes</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>The TCP/UDP buffer sizes to be
used during outbound communication. Size is bytes.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>receiveBufferSize</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>65536 bytes</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>The TCP/UDP buffer sizes to be
used during inbound communication. Size is bytes.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>option.XXX</code></p></td><t
d colspan="1" rowspan="1"
class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.11/2.10.4:</strong> Allows to configure
additional netty options using "option." as prefix. For example
"option.child.keepAlive=false" to set the netty option "child.keepAlive=false".
See the Netty documentation for possible options that can be
used.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>corePoolSize</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>10</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The number of allocated threads at
component startup. Defaults to 10. <strong>Note:</strong> This option is
removed from Camel 2.9.2 onwards. As we rely on Nettys default
settings.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>maxPoolSize</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>100</code></p></td><td colspan
="1" rowspan="1" class="confluenceTd"><p>The maximum number of threads that
may be allocated to this endpoint. Defaults to 100. <strong>Note:</strong> This
option is removed from Camel 2.9.2 onwards. As we rely on Nettys default
settings.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>disconnect</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Whether or not to disconnect(close) from
Netty Channel right after use. Can be used for both consumer and
producer.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>lazyChannelCreation</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Channels can be lazily created
to avoid exceptions, if the remote server is not up and running when the Camel
producer is started.</p></td></tr><tr><td colspan="1" rowspa
n="1" class="confluenceTd"><p><code>transferExchange</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Only used for TCP. You can
transfer the exchange over the wire instead of just the body. The following
fields are transferred: In body, Out body, fault body, In headers, Out headers,
fault headers, exchange properties, exchange exception. This requires that the
objects are serializable. Camel will exclude any non-serializable objects and
log it at WARN level.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>disconnectOnNoReply</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>If sync is enabled then this
option dictates NettyConsumer if it should disconnect where there is no reply
to send back.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>
noReplyLogLevel</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>WARN</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>If sync is enabled this option dictates NettyConsumer
which logging level to use when logging a there is no reply to send back.
Values are: <code>FATAL, ERROR, INFO, DEBUG, OFF</code>.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>serverExceptionCaughtLogLevel</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>WARN</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11.1:</strong>
If the server (NettyConsumer) catches an exception then its logged using this
logging level.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>serverClosedChannelExceptionCaughtLogLevel</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>DEBUG</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel
2.11.1:</strong> If the server (NettyConsumer) catches an
<code>java.nio.channels.ClosedChannelException</code> then its logged using
this logging level. This is used to avoid logging the closed channel
exceptions, as clients can disconnect abruptly and then cause a flod of closed
exceptions in the Netty server.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>allowDefaultCodec</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong> The netty
component installs a default codec if both, encoder/deocder is null and
textline is false. Setting allowDefaultCodec to false prevents the netty
component from installing a default codec as the first element in the filter
chain.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>textline</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td
><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel
>2.4:</strong> Only used for TCP. If no codec is specified, you can use this
>flag to indicate a text line based codec; if not specified or the value is
>false, then Object Serialization is assumed over TCP.</p></td></tr><tr><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p><code>delimiter</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p><code>LINE</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong> The delimiter
>to use for the textline codec. Possible values are <code>LINE</code> and
><code>NULL</code>.</p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>decoderMaxLineLength</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><code>1024</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong>
>The max line length to use for the textline codec.</p></td></tr><tr><td
>colspan="1" rowspan=
"1" class="confluenceTd"><p><code>autoAppendDelimiter</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong>
Whether or not to auto append missing end delimiter when sending using the
textline codec.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>encoding</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong> The encoding (a
charset name) to use for the textline codec. If not provided, Camel will use
the JVM default Charset.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>workerCount</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> When netty
works on nio mode, it uses defaul
t workerCount parameter from Netty, which is cpu_core_threads*2. User can use
this operation to override the default workerCount from
Netty</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>sslContextParameters</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> SSL
configuration using an
<code>org.apache.camel.util.jsse.SSLContextParameters</code> instance. See <a
shape="rect" href="#Netty-UsingtheJSSEConfigurationUtility">Using the JSSE
Configuration Utility</a>.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>receiveBufferSizePredictor</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong>
Configures the buffer size predictor. See details at Jetty documentation and
this <a shape="rect" class="e
xternal-link"
href="http://lists.jboss.org/pipermail/netty-users/2010-January/001958.html"
rel="nofollow">mail thread</a>.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>requestTimeout</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.11.1:</strong> Allows to
use a timeout for the Netty producer when calling a remote server. By default
no timeout is in use. The value is in milli seconds, so eg <code>30000</code>
is 30 seconds. The requestTimeout is using Netty's ReadTimeoutHandler to
trigger the timeout.<strong> Camel 2.16, 2.15.3</strong> you can also override
this setting by setting the CamelNettyRequestTimeout
header.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>needClientAuth</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"
><p><strong>Camel 2.11:</strong> Configures whether the server needs client
>authentication when using SSL.</p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>orderedThreadPoolExecutor</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel
>2.10.2:</strong> Whether to use ordered thread pool, to ensure events are
>processed orderly on the same channel. See details at the netty javadoc of
><code>org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor</code>
> for more details.</p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>maximumPoolSize</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p><code>16</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.2:</strong> The core
>pool size for the ordered thread pool, if its in use.</p><p><strong>Since
>Camel 2.14.1</strong>: This opt
ion is move the NettyComponent.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>producerPoolEnabled</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.4/Camel
2.11:</strong> Producer only. Whether producer pool is enabled or not.
<strong>Important:</strong> Do not turn this off, as the pooling is needed for
handling concurrency and reliable request/reply.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>producerPoolMaxActive</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>-1</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.3:</strong>
Producer only. Sets the cap on the number of objects that can be allocated by
the pool (checked out to clients, or idle awaiting checkout) at a given time.
Use a negative value for no limit.</p></td></tr><tr><td colspan="1" rows
pan="1" class="confluenceTd"><p><code>producerPoolMinIdle</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.3:</strong>
Producer only. Sets the minimum number of instances allowed in the producer
pool before the evictor thread (if active) spawns new
objects.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>producerPoolMaxIdle</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>100</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.3:</strong>
Producer only. Sets the cap on the number of "idle" instances in the
pool.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>producerPoolMinEvictableIdle</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>300000</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.3:</strong>
Producer only. Sets the minimum amount of time (value in millis) an object may
sit idle in the pool before it is eligible for eviction by the idle object
evictor.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>bootstrapConfiguration</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong>
Consumer only. Allows to configure the Netty ServerBootstrap options using a
<code>org.apache.camel.component.netty.NettyServerBootstrapConfiguration</code>
instance. This can be used to reuse the same configuration for multiple
consumers, to align their configuration more easily.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>bossPoll</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> To use a
explicit <cod
e>org.jboss.netty.channel.socket.nio.BossPool</code> as the boss thread pool.
For example to share a thread pool with multiple consumers. By default each
consumer has their own boss pool with 1 core thread.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>workerPool</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> To use a
explicit <code>org.jboss.netty.channel.socket.nio.WorkerPool</code> as the
worker thread pool. For example to share a thread pool with multiple consumers.
By default each consumer has their own worker pool with 2 x cpu count core
threads.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">channelGroup</td><td colspan="1" rowspan="1"
class="confluenceTd"><span>null</span></td><td colspan="1" rowspan="1"
class="confluenceTd"><span><strong>Camel 2.17 </strong>To use a explicit
</span><code>io.netty.chann
el.group.ChannelGroup</code><span> for example to broadact a message to
multiple channels.</span></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>networkInterface</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> Consumer only.
When using UDP then this option can be used to specify a network interface by
its name, such as <code>eth0</code> to join a multicast
group.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>udpConnectionlessSending</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.15:</strong>
Producer only.  This option supports connection less udp sending which is
a real fire and forget. A connected udp send receive the
PortUnreachableException if no one is listen on the receiving port.</p></td><
/tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>clientMode</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><strong>Camel 2.15:</strong> Consumer only. If
the <code>clientMode</code> is true, netty consumer will connect the address as
a TCP client.</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>useChannelBuffer</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><strong>Camel 2.16:</strong> Producer only. If
the <code><span>useChannelBuffer</span></code> is true, netty producer will
turn the message body into channelBuffer before sending it
out.</td></tr></tbody></table></div></div>
-
-
-<h3 id="Netty-RegistrybasedOptions">Registry based Options</h3><p>Codec
Handlers and SSL Keystores can be enlisted in the <a shape="rect"
href="registry.html">Registry</a>, such as in the Spring XML file.<br
clear="none"> The values that could be passed in, are the following:</p><div
class="confluenceTableSmall"><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>passphrase</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>password setting to use in
order to encrypt/decrypt payloads sent using SSH</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>keyStoreFormat</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>keystore format to be used for payload
encryption. Defaults to "JKS" if not set</p></td></tr><tr><td c
olspan="1" rowspan="1"
class="confluenceTd"><p><code>securityProvider</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Security provider to be used for payload
encryption. Defaults to "SunX509" if not set.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>keyStoreFile</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>deprecated:</strong>
Client side certificate keystore to be used for encryption</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>trustStoreFile</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>deprecated:</strong> Server side
certificate keystore to be used for encryption</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>keyStoreResource</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11.1:</strong>
Client side certificate keystore to be used for encryption. Is loaded by
default from classpath
, but you can prefix with <code>"classpath:"</code>, <code>"file:"</code>, or
<code>"http:"</code> to load the resource from different
systems.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>trustStoreResource</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.11.1:</strong> Server side
certificate keystore to be used for encryption. Is loaded by default from
classpath, but you can prefix with <code>"classpath:"</code>,
<code>"file:"</code>, or <code>"http:"</code> to load the resource from
different systems.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>sslHandler</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Reference to a class that could be used to
return an SSL Handler</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>encoder</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>A custom <code>ChannelHandler</code> class
that can be
used to perform special marshalling of outbound payloads. Must override
<code>org.jboss.netty.channel.ChannelDownStreamHandler</code>.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>encorders</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>A list of encoders to be used. You can use
a String which have values separated by comma, and have the values be looked up
in the <a shape="rect" href="registry.html">Registry</a>. Just remember to
prefix the value with # so Camel knows it should lookup.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>decoder</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>A custom <code>ChannelHandler</code> class
that can be used to perform special marshalling of inbound payloads. Must
override
<code>org.jboss.netty.channel.ChannelUpStreamHandler</code>.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>decoders</code></p></td><td colspan="1" ro
wspan="1" class="confluenceTd"><p>A list of decoders to be used. You can use a
String which have values separated by comma, and have the values be looked up
in the <a shape="rect" href="registry.html">Registry</a>. Just remember to
prefix the value with # so Camel knows it should
lookup.</p></td></tr></tbody></table></div></div>
-
-
-<p><strong>Important:</strong> Read below about using non shareable
encoders/decoders.</p><h4 id="Netty-Usingnonshareableencodersordecoders">Using
non shareable encoders or decoders</h4><p>If your encoders or decoders is not
shareable (eg they have the @Shareable class annotation), then your
encoder/decoder must implement the
<code>org.apache.camel.component.netty.ChannelHandlerFactory</code> interface,
and return a new instance in the <code>newChannelHandler</code> method. This is
to ensure the encoder/decoder can safely be used. If this is not the case, then
the Netty component will log a WARN when<br clear="none"> an endpoint is
created.</p><p>The Netty component offers a
<code>org.apache.camel.component.netty.ChannelHandlerFactories</code> factory
class, that has a number of commonly used methods.</p><h3
id="Netty-SendingMessagesto/fromaNettyendpoint">Sending Messages to/from a
Netty endpoint</h3><h4 id="Netty-NettyProducer">Netty Producer</h4><p>In
Producer mode, the component
provides the ability to send payloads to a socket endpoint<br clear="none">
using either TCP or UDP protocols (with optional SSL support).</p><p>The
producer mode supports both one-way and request-response based
operations.</p><h4 id="Netty-NettyConsumer">Netty Consumer</h4><p>In Consumer
mode, the component provides the ability to:</p><ul
class="alternate"><li>listen on a specified socket using either TCP or UDP
protocols (with optional SSL support),</li><li>receive requests on the socket
using text/xml, binary and serialized object based payloads and</li><li>send
them along on a route as message exchanges.</li></ul><p>The consumer mode
supports both one-way and request-response based
operations.</p><p> </p><h3 id="Netty-Headers">Headers</h3><p>The following
headers are filled for the exchanges created by the Netty consumer:</p><div
class="confluenceTableSmall"><div class="table-wrap"><table
class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1"
class="confluenceTh"><p
>Header key</p></th><th colspan="1" rowspan="1"
>class="confluenceTh">Class</th><th colspan="1" rowspan="1"
>class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
>rowspan="1"
>class="confluenceTd"><p><code>NettyConstants.NETTY_CHANNEL_HANDLER_CONTEXT</code>
> / <code>CamelNettyChannelHandlerContext</code></p></td><td colspan="1"
>rowspan="1"
>class="confluenceTd"><code>org.jboss.netty.channel.ChannelHandlerContext</code></td><td
> colspan="1" rowspan="1"
>class="confluenceTd"><p><code><span>ChannelHandlerContext
></span></code>instance associated with the connection received by
>netty.</p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>NettyConstants.NETTY_MESSAGE_EVENT</code> /
><code>CamelNettyMessageEvent</code></p></td><td colspan="1" rowspan="1"
>class="confluenceTd"><code><span>org.jboss.netty.channel.</span>MessageEvent</code></td><td
> colspan="1" rowspan="1"
>class="confluenceTd"><p><span><code><span>MessageEvent </span></code>instance
>associated with
the connection received by netty.</span></p></td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>NettyConstants.NETTY_REMOTE_ADDRESS</code> /
<code>CamelNettyRemoteAddress</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><code>java.net.SocketAddress</code></td><td colspan="1"
rowspan="1" class="confluenceTd">Remote address of the incoming socket
connection.</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>NettyConstants.NETTY_LOCAL_ADDRESS</code> /
<code>CamelNettyLocalAddress</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><code><span>java.net.</span><span>SocketAddress</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd"><span>Local address of the
incoming socket connection.</span></td></tr></tbody></table></div></div>
-
-
-<h3 id="Netty-UsageSamples">Usage Samples</h3><h4
id="Netty-AUDPNettyendpointusingRequest-Replyandserializedobjectpayload">A UDP
Netty endpoint using Request-Reply and serialized object payload</h4><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[RouteBuilder builder = new RouteBuilder() {
+</plain-text-body><p>This component supports producer and consumer endpoints
for both TCP and UDP.</p><p>You can append query options to the URI in the
following format, <code>?option=value&option=value&...</code></p><h3
id="Netty-Options">Options</h3><parameter
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>keepAlive</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Setting to ensure socket is not
closed due to inactivity</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>tcpNoDelay</code></p></td><td c
olspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Setting to improve TCP protocol
performance</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>backlog</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p> </p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.9.6/2.10.4/2.11:</strong> Allows to
configure a backlog for netty consumer (server). Note the backlog is just a
best effort depending on the OS. Setting this option to a value such as
<code>200</code>, <code>500</code> or <code>1000</code>, tells the TCP stack
how long the "accept" queue can be. If this option is not configured, then the
backlog depends on OS setting.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>broadcast</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluence
Td"><p>Setting to choose Multicast over UDP</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>connectTimeout</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>10000</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Time to wait for a socket
connection to be available. Value is in millis.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>reuseAddress</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Setting to facilitate socket
multiplexing</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>sync</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>Setting to set endpoint as one-way or
request-response</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>synchronous</
code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.10:</strong> Whether <a shape="rect"
href="asynchronous-routing-engine.html">Asynchronous Routing Engine</a> is not
in use. <code>false</code> then the <a shape="rect"
href="asynchronous-routing-engine.html">Asynchronous Routing Engine</a> is
used, <code>true</code> to force processing synchronous.</p></td></tr><tr><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>ssl</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Setting to specify whether SSL
encryption is applied to this endpoint</p></td></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>sslClientCertHeaders</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p
><strong>Camel 2.12:</strong> When enabled and in SSL mode, then the Netty
>consumer will enrich the Camel <a shape="rect"
>href="message.html">Message</a> with headers having information about the
>client certificate such as subject name, issuer name, serial number, and the
>valid date range.</p></td></tr><tr><td colspan="1" rowspan="1"
>class="confluenceTd"><p><code>sendBufferSize</code></p></td><td colspan="1"
>rowspan="1" class="confluenceTd"><p><code>65536 bytes</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p>The TCP/UDP buffer sizes to
>be used during outbound communication. Size is bytes.</p></td></tr><tr><td
>colspan="1" rowspan="1"
>class="confluenceTd"><p><code>receiveBufferSize</code></p></td><td
>colspan="1" rowspan="1" class="confluenceTd"><p><code>65536
>bytes</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The
>TCP/UDP buffer sizes to be used during inbound communication. Size is
>bytes.</p></td></tr><tr><td colspan="1" rowspan="1" class="conf
luenceTd"><p><code>option.XXX</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.11/2.10.4:</strong> Allows to configure
additional netty options using "option." as prefix. For example
"option.child.keepAlive=false" to set the netty option "child.keepAlive=false".
See the Netty documentation for possible options that can be
used.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>corePoolSize</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>10</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>The number of allocated threads at
component startup. Defaults to 10. <strong>Note:</strong> This option is
removed from Camel 2.9.2 onwards. As we rely on Nettys default
settings.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>maxPoolSize</code></p></td><td colspan="1"
rowspan="1" class="conflu
enceTd"><p><code>100</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p>The maximum number of threads that may be allocated to
this endpoint. Defaults to 100. <strong>Note:</strong> This option is removed
from Camel 2.9.2 onwards. As we rely on Nettys default
settings.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>disconnect</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Whether or not to disconnect(close) from
Netty Channel right after use. Can be used for both consumer and
producer.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>lazyChannelCreation</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Channels can be lazily created
to avoid exceptions, if the remote server is not up and running when the Camel
producer is s
tarted.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>transferExchange</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Only used for TCP. You can transfer the
exchange over the wire instead of just the body. The following fields are
transferred: In body, Out body, fault body, In headers, Out headers, fault
headers, exchange properties, exchange exception. This requires that the
objects are serializable. Camel will exclude any non-serializable objects and
log it at WARN level.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>disconnectOnNoReply</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>If sync is enabled then this
option dictates NettyConsumer if it should disconnect where there is no reply
to send back.</p></td></tr><tr><td colspan
="1" rowspan="1"
class="confluenceTd"><p><code>noReplyLogLevel</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>WARN</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>If sync is enabled this option dictates
NettyConsumer which logging level to use when logging a there is no reply to
send back. Values are: <code>FATAL, ERROR, INFO, DEBUG,
OFF</code>.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>serverExceptionCaughtLogLevel</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>WARN</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11.1:</strong>
If the server (NettyConsumer) catches an exception then its logged using this
logging level.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>serverClosedChannelExceptionCaughtLogLevel</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>DEBUG</code></p></td><td
colspan="1" ro
wspan="1" class="confluenceTd"><p><strong>Camel 2.11.1:</strong> If the server
(NettyConsumer) catches an
<code>java.nio.channels.ClosedChannelException</code> then its logged using
this logging level. This is used to avoid logging the closed channel
exceptions, as clients can disconnect abruptly and then cause a flod of closed
exceptions in the Netty server.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>allowDefaultCodec</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong> The netty
component installs a default codec if both, encoder/deocder is null and
textline is false. Setting allowDefaultCodec to false prevents the netty
component from installing a default codec as the first element in the filter
chain.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>textline</code></p></td><td colspan="1"
rowspan="1" cla
ss="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><p><strong>Camel 2.4:</strong> Only used for TCP. If no
codec is specified, you can use this flag to indicate a text line based codec;
if not specified or the value is false, then Object Serialization is assumed
over TCP.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>delimiter</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>LINE</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong> The delimiter
to use for the textline codec. Possible values are <code>LINE</code> and
<code>NULL</code>.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>decoderMaxLineLength</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>1024</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong> The
max line length to use for the textline c
odec.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>autoAppendDelimiter</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong>
Whether or not to auto append missing end delimiter when sending using the
textline codec.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>encoding</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong> The encoding (a
charset name) to use for the textline codec. If not provided, Camel will use
the JVM default Charset.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>workerCount</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</stron
g> When netty works on nio mode, it uses default workerCount parameter from
Netty, which is cpu_core_threads*2. User can use this operation to override the
default workerCount from Netty</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>sslContextParameters</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> SSL
configuration using an
<code>org.apache.camel.util.jsse.SSLContextParameters</code> instance. See <a
shape="rect" href="#Netty-UsingtheJSSEConfigurationUtility">Using the JSSE
Configuration Utility</a>.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>receiveBufferSizePredictor</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong>
Configures the buffer size predictor. See details at Jetty
documentation and this <a shape="rect" class="external-link"
href="http://lists.jboss.org/pipermail/netty-users/2010-January/001958.html"
rel="nofollow">mail thread</a>.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>requestTimeout</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.11.1:</strong> Allows to
use a timeout for the Netty producer when calling a remote server. By default
no timeout is in use. The value is in milli seconds, so eg <code>30000</code>
is 30 seconds. The requestTimeout is using Netty's ReadTimeoutHandler to
trigger the timeout.<strong> Camel 2.16, 2.15.3</strong> you can also override
this setting by setting the CamelNettyRequestTimeout
header.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>needClientAuth</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>false</code></p></td><
td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel
2.11:</strong> Configures whether the server needs client authentication when
using SSL.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>orderedThreadPoolExecutor</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.2:</strong>
Whether to use ordered thread pool, to ensure events are processed orderly on
the same channel. See details at the netty javadoc of
<code>org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor</code>
for more details.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>maximumPoolSize</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>16</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.2:</strong> The core
pool size for the ordered thread pool, if its in use.</p><
p><strong>Since Camel 2.14.1</strong>: This option is move the
NettyComponent.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>producerPoolEnabled</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.4/Camel
2.11:</strong> Producer only. Whether producer pool is enabled or not.
<strong>Important:</strong> Do not turn this off, as the pooling is needed for
handling concurrency and reliable request/reply.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>producerPoolMaxActive</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>-1</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.3:</strong>
Producer only. Sets the cap on the number of objects that can be allocated by
the pool (checked out to clients, or idle awaiting checkout) at a given time.
Use a negative value for
no limit.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>producerPoolMinIdle</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.3:</strong>
Producer only. Sets the minimum number of instances allowed in the producer
pool before the evictor thread (if active) spawns new
objects.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>producerPoolMaxIdle</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>100</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10.3:</strong>
Producer only. Sets the cap on the number of "idle" instances in the
pool.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>producerPoolMinEvictableIdle</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>300000</code></p></td><td
colspan="1" rowspan="1" class="c
onfluenceTd"><p><strong>Camel 2.10.3:</strong> Producer only. Sets the minimum
amount of time (value in millis) an object may sit idle in the pool before it
is eligible for eviction by the idle object evictor.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>bootstrapConfiguration</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong>
Consumer only. Allows to configure the Netty ServerBootstrap options using a
<code>org.apache.camel.component.netty.NettyServerBootstrapConfiguration</code>
instance. This can be used to reuse the same configuration for multiple
consumers, to align their configuration more easily.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>bossPoll</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><str
ong>Camel 2.12:</strong> To use a explicit
<code>org.jboss.netty.channel.socket.nio.BossPool</code> as the boss thread
pool. For example to share a thread pool with multiple consumers. By default
each consumer has their own boss pool with 1 core thread.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>workerPool</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong> To use a
explicit <code>org.jboss.netty.channel.socket.nio.WorkerPool</code> as the
worker thread pool. For example to share a thread pool with multiple consumers.
By default each consumer has their own worker pool with 2 x cpu count core
threads.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd">channelGroup</td><td colspan="1" rowspan="1"
class="confluenceTd"><span>null</span></td><td colspan="1" rowspan="1"
class="confluenceTd"><span><strong>Camel 2.17 </stron
g>To use a explicit
</span><code>io.netty.channel.group.ChannelGroup</code><span> for example to
broadact a message to multiple channels.</span></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>networkInterface</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.12:</strong>
Consumer only. When using UDP then this option can be used to specify a network
interface by its name, such as <code>eth0</code> to join a multicast
group.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>udpConnectionlessSending</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.15:</strong>
Producer only.  This option supports connection less udp sending which is
a real fire and forget. A connected udp send receive the
PortUnreachableException if no
one is listen on the receiving port.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>clientMode</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><code>false</code></td><td
colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.15:</strong>
Consumer only. If the <code>clientMode</code> is true, netty consumer will
connect the address as a TCP client.</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>useChannelBuffer</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><code>false</code></td><td colspan="1"
rowspan="1" class="confluenceTd"><strong>Camel 2.16:</strong> Producer only. If
the <code><span>useChannelBuffer</span></code> is true, netty producer will
turn the message body into channelBuffer before sending it
out.</td></tr></tbody></table></div></rich-text-body><h3
id="Netty-RegistrybasedOptions">Registry based Options</h3><p>Codec Handlers
and SSL Keystores can be enlisted in the <a shape="rect" href="
registry.html">Registry</a>, such as in the Spring XML file.<br clear="none">
The values that could be passed in, are the following:</p><parameter
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>passphrase</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>password setting to use in
order to encrypt/decrypt payloads sent using SSH</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>keyStoreFormat</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>keystore format to be used for payload
encryption. Defaults to "JKS" if not set</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>securityProvider</code></p></td><td
colspan="1" ro
wspan="1" class="confluenceTd"><p>Security provider to be used for payload
encryption. Defaults to "SunX509" if not set.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>keyStoreFile</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>deprecated:</strong>
Client side certificate keystore to be used for encryption</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>trustStoreFile</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p><strong>deprecated:</strong> Server side
certificate keystore to be used for encryption</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>keyStoreResource</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11.1:</strong>
Client side certificate keystore to be used for encryption. Is loaded by
default from classpath, but you can prefix with <code>"classpath:"</code>,
<code>"file:"</code>, or <code>"http:"</code> to l
oad the resource from different systems.</p></td></tr><tr><td colspan="1"
rowspan="1" class="confluenceTd"><p><code>trustStoreResource</code></p></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.11.1:</strong>
Server side certificate keystore to be used for encryption. Is loaded by
default from classpath, but you can prefix with <code>"classpath:"</code>,
<code>"file:"</code>, or <code>"http:"</code> to load the resource from
different systems.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>sslHandler</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>Reference to a class that could be used to
return an SSL Handler</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>encoder</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>A custom <code>ChannelHandler</code> class
that can be used to perform special marshalling of outbound payloads. Must
override <code>org.jboss.netty.channel.
ChannelDownStreamHandler</code>.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>encorders</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>A list of encoders to be used. You can use
a String which have values separated by comma, and have the values be looked up
in the <a shape="rect" href="registry.html">Registry</a>. Just remember to
prefix the value with # so Camel knows it should lookup.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>decoder</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>A custom <code>ChannelHandler</code> class
that can be used to perform special marshalling of inbound payloads. Must
override
<code>org.jboss.netty.channel.ChannelUpStreamHandler</code>.</p></td></tr><tr><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code>decoders</code></p></td><td colspan="1"
rowspan="1" class="confluenceTd"><p>A list of decoders to be used. You can use
a String which have values
separated by comma, and have the values be looked up in the <a shape="rect"
href="registry.html">Registry</a>. Just remember to prefix the value with # so
Camel knows it should
lookup.</p></td></tr></tbody></table></div></rich-text-body><p><strong>Important:</strong>
Read below about using non shareable encoders/decoders.</p><h4
id="Netty-Usingnonshareableencodersordecoders">Using non shareable encoders or
decoders</h4><p>If your encoders or decoders is not shareable (eg they have the
@Shareable class annotation), then your encoder/decoder must implement the
<code>org.apache.camel.component.netty.ChannelHandlerFactory</code> interface,
and return a new instance in the <code>newChannelHandler</code> method. This is
to ensure the encoder/decoder can safely be used. If this is not the case, then
the Netty component will log a WARN when<br clear="none"> an endpoint is
created.</p><p>The Netty component offers a
<code>org.apache.camel.component.netty.ChannelHandlerFactories</code> facto
ry class, that has a number of commonly used methods.</p><h3
id="Netty-SendingMessagesto/fromaNettyendpoint">Sending Messages to/from a
Netty endpoint</h3><h4 id="Netty-NettyProducer">Netty Producer</h4><p>In
Producer mode, the component provides the ability to send payloads to a socket
endpoint<br clear="none"> using either TCP or UDP protocols (with optional SSL
support).</p><p>The producer mode supports both one-way and request-response
based operations.</p><h4 id="Netty-NettyConsumer">Netty Consumer</h4><p>In
Consumer mode, the component provides the ability to:</p><ul
class="alternate"><li>listen on a specified socket using either TCP or UDP
protocols (with optional SSL support),</li><li>receive requests on the socket
using text/xml, binary and serialized object based payloads and</li><li>send
them along on a route as message exchanges.</li></ul><p>The consumer mode
supports both one-way and request-response based
operations.</p><p> </p><h3 id="Netty-Headers">Headers</h3><
p>The following headers are filled for the exchanges created by the Netty
consumer:</p><parameter
ac:name="class">confluenceTableSmall</parameter><rich-text-body><div
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1"
rowspan="1" class="confluenceTh"><p>Header key</p></th><th colspan="1"
rowspan="1" class="confluenceTh">Class</th><th colspan="1" rowspan="1"
class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1"
rowspan="1"
class="confluenceTd"><p><code>NettyConstants.NETTY_CHANNEL_HANDLER_CONTEXT</code>
/ <code>CamelNettyChannelHandlerContext</code></p></td><td colspan="1"
rowspan="1"
class="confluenceTd"><code>org.jboss.netty.channel.ChannelHandlerContext</code></td><td
colspan="1" rowspan="1"
class="confluenceTd"><p><code><span>ChannelHandlerContext
</span></code>instance associated with the connection received by
netty.</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>NettyConstants.NETTY_MESSAGE_EVENT</code> / <co
de>CamelNettyMessageEvent</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><code><span>org.jboss.netty.channel.</span>MessageEvent</code></td><td
colspan="1" rowspan="1" class="confluenceTd"><p><span><code><span>MessageEvent
</span></code>instance associated with the connection received by
netty.</span></p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p><code>NettyConstants.NETTY_REMOTE_ADDRESS</code> /
<code>CamelNettyRemoteAddress</code></p></td><td colspan="1" rowspan="1"
class="confluenceTd"><code>java.net.SocketAddress</code></td><td colspan="1"
rowspan="1" class="confluenceTd">Remote address of the incoming socket
connection.</td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><code>NettyConstants.NETTY_LOCAL_ADDRESS</code> /
<code>CamelNettyLocalAddress</code></td><td colspan="1" rowspan="1"
class="confluenceTd"><code><span>java.net.</span><span>SocketAddress</span></code></td><td
colspan="1" rowspan="1" class="confluenceTd"><span>Lo
cal address of the incoming socket
connection.</span></td></tr></tbody></table></div></rich-text-body><h3
id="Netty-UsageSamples">Usage Samples</h3><h4
id="Netty-AUDPNettyendpointusingRequest-Replyandserializedobjectpayload">A UDP
Netty endpoint using Request-Reply and serialized object
payload</h4><plain-text-body>RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("netty:udp://localhost:5155?sync=true")
+ from("netty:udp://localhost:5155?sync=true")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
Poetry poetry = (Poetry) exchange.getIn().getBody();
- poetry.setPoet("Dr. Sarojini Naidu");
+ poetry.setPoet("Dr. Sarojini Naidu");
exchange.getOut().setBody(poetry);
}
}
}
};
-]]></script>
-</div></div><h4
id="Netty-ATCPbasedNettyconsumerendpointusingOne-waycommunication">A TCP based
Netty consumer endpoint using One-way communication</h4><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[RouteBuilder builder = new RouteBuilder() {
+</plain-text-body><h4
id="Netty-ATCPbasedNettyconsumerendpointusingOne-waycommunication">A TCP based
Netty consumer endpoint using One-way
communication</h4><plain-text-body>RouteBuilder builder = new RouteBuilder() {
public void configure() {
- from("netty:tcp://localhost:5150")
- .to("mock:result");
+ from("netty:tcp://localhost:5150")
+ .to("mock:result");
}
};
-]]></script>
-</div></div><h4
id="Netty-AnSSL/TCPbasedNettyconsumerendpointusingRequest-Replycommunication">An
SSL/TCP based Netty consumer endpoint using Request-Reply
communication</h4><h5 id="Netty-UsingtheJSSEConfigurationUtility">Using the
JSSE Configuration Utility</h5><p>As of Camel 2.9, the Netty component supports
SSL/TLS configuration through the <a shape="rect"
href="camel-configuration-utilities.html">Camel JSSE Configuration
Utility</a>.  This utility greatly decreases the amount of component
specific code you need to write and is configurable at the endpoint and
component levels.  The following examples demonstrate how to use the
utility with the Netty component.</p><h6
id="Netty-Programmaticconfigurationofthecomponent">Programmatic configuration
of the component</h6><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[KeyStoreParameters ksp = new
KeyStoreParameters();
-ksp.setResource("/users/home/server/keystore.jks");
-ksp.setPassword("keystorePassword");
+</plain-text-body><h4
id="Netty-AnSSL/TCPbasedNettyconsumerendpointusingRequest-Replycommunication">An
SSL/TCP based Netty consumer endpoint using Request-Reply
communication</h4><h5 id="Netty-UsingtheJSSEConfigurationUtility">Using the
JSSE Configuration Utility</h5><p>As of Camel 2.9, the Netty component supports
SSL/TLS configuration through the <a shape="rect"
href="camel-configuration-utilities.html">Camel JSSE Configuration
Utility</a>.  This utility greatly decreases the amount of component
specific code you need to write and is configurable at the endpoint and
component levels.  The following examples demonstrate how to use the
utility with the Netty component.</p><h6
id="Netty-Programmaticconfigurationofthecomponent">Programmatic configuration
of the component</h6><plain-text-body>KeyStoreParameters ksp = new
KeyStoreParameters();
+ksp.setResource("/users/home/server/keystore.jks");
+ksp.setPassword("keystorePassword");
KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyStore(ksp);
-kmp.setKeyPassword("keyPassword");
+kmp.setKeyPassword("keyPassword");
SSLContextParameters scp = new SSLContextParameters();
scp.setKeyManagers(kmp);
-NettyComponent nettyComponent = getContext().getComponent("netty",
NettyComponent.class);
+NettyComponent nettyComponent = getContext().getComponent("netty",
NettyComponent.class);
nettyComponent.setSslContextParameters(scp);
-]]></script>
-</div></div><h6 id="Netty-SpringDSLbasedconfigurationofendpoint">Spring DSL
based configuration of endpoint</h6><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[...
+</plain-text-body><h6 id="Netty-SpringDSLbasedconfigurationofendpoint">Spring
DSL based configuration of endpoint</h6><parameter
ac:name="">xml</parameter><plain-text-body>...
<camel:sslContextParameters
- id="sslContextParameters">
+ id="sslContextParameters">
<camel:keyManagers
- keyPassword="keyPassword">
+ keyPassword="keyPassword">
<camel:keyStore
- resource="/users/home/server/keystore.jks"
- password="keystorePassword"/>
+ resource="/users/home/server/keystore.jks"
+ password="keystorePassword"/>
</camel:keyManagers>
</camel:sslContextParameters>...
...
- <to
uri="netty:tcp://localhost:5150?sync=true&ssl=true&sslContextParameters=#sslContextParameters"/>
+ <to
uri="netty:tcp://localhost:5150?sync=true&ssl=true&sslContextParameters=#sslContextParameters"/>
...
-]]></script>
-</div></div><h5
id="Netty-UsingBasicSSL/TLSconfigurationontheJettyComponent">Using Basic
SSL/TLS configuration on the Jetty Component</h5><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[JndiRegistry registry = new
JndiRegistry(createJndiContext());
-registry.bind("password", "changeit");
-registry.bind("ksf", new
File("src/test/resources/keystore.jks"));
-registry.bind("tsf", new
File("src/test/resources/keystore.jks"));
+</plain-text-body><h5
id="Netty-UsingBasicSSL/TLSconfigurationontheJettyComponent">Using Basic
SSL/TLS configuration on the Jetty Component</h5><plain-text-body>JndiRegistry
registry = new JndiRegistry(createJndiContext());
+registry.bind("password", "changeit");
+registry.bind("ksf", new File("src/test/resources/keystore.jks"));
+registry.bind("tsf", new File("src/test/resources/keystore.jks"));
context.createRegistry(registry);
context.addRoutes(new RouteBuilder() {
public void configure() {
String netty_ssl_endpoint =
-
"netty:tcp://localhost:5150?sync=true&ssl=true&passphrase=#password"
- + "&keyStoreFile=#ksf&trustStoreFile=#tsf";
+
"netty:tcp://localhost:5150?sync=true&ssl=true&passphrase=#password"
+ + "&keyStoreFile=#ksf&trustStoreFile=#tsf";
String return_string =
- "When You Go Home, Tell Them Of Us And Say,"
- + "For Your Tomorrow, We Gave Our Today.";
+ "When You Go Home, Tell Them Of Us And Say,"
+ + "For Your Tomorrow, We Gave Our Today.";
from(netty_ssl_endpoint)
.process(new Processor() {
@@ -183,136 +150,45 @@ context.addRoutes(new RouteBuilder() {
}
}
});
-]]></script>
-</div></div><h5
id="Netty-GettingaccesstoSSLSessionandtheclientcertificate">Getting access to
SSLSession and the client certificate</h5><p><strong>Available as of Camel
2.12</strong></p><p>You can get access to the
<code>javax.net.ssl.SSLSession</code> if you eg need to get details about the
client certificate. When <code>ssl=true</code> then the <a shape="rect"
href="netty.html">Netty</a> component will store the <code>SSLSession</code> as
a header on the Camel <a shape="rect" href="message.html">Message</a> as shown
below:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[SSLSession session =
exchange.getIn().getHeader(NettyConstants.NETTY_SSL_SESSION, SSLSession.class);
+</plain-text-body><h5
id="Netty-GettingaccesstoSSLSessionandtheclientcertificate">Getting access to
SSLSession and the client certificate</h5><p><strong>Available as of Camel
2.12</strong></p><p>You can get access to the
<code>javax.net.ssl.SSLSession</code> if you eg need to get details about the
client certificate. When <code>ssl=true</code> then the <a shape="rect"
href="netty.html">Netty</a> component will store the <code>SSLSession</code> as
a header on the Camel <a shape="rect" href="message.html">Message</a> as shown
below:</p><plain-text-body>SSLSession session =
exchange.getIn().getHeader(NettyConstants.NETTY_SSL_SESSION, SSLSession.class);
// get the first certificate which is client certificate
javax.security.cert.X509Certificate cert =
session.getPeerCertificateChain()[0];
Principal principal = cert.getSubjectDN();
-]]></script>
-</div></div><p>Remember to set <code>needClientAuth=true</code> to
authenticate the client, otherwise <code>SSLSession</code> cannot access
information about the client certificate, and you may get an exception
<code>javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated</code>.
You may also get this exception if the client certificate is expired or not
valid etc.</p><div class="confluence-information-macro
confluence-information-macro-tip"><span class="aui-icon aui-icon-small
aui-iconfont-approve confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>The option
<code>sslClientCertHeaders</code> can be set to <code>true</code> which then
enriches the Camel <a shape="rect" href="message.html">Message</a> with headers
having details about the client certificate. For example the subject name is
readily available in the header
<code>CamelNettySSLClientCertSubjectName</code>.</p></div></div><h4
id="Netty-UsingMultipleCodecs">Using Multiple C
odecs</h4><p>In certain cases it may be necessary to add chains of encoders
and decoders to the netty pipeline. To add multpile codecs to a camel netty
endpoint the 'encoders' and 'decoders' uri parameters should be used. Like the
'encoder' and 'decoder' parameters they are used to supply references (to lists
of ChannelUpstreamHandlers and ChannelDownstreamHandlers) that should be added
to the pipeline. Note that if encoders is specified then the encoder param will
be ignored, similarly for decoders and the decoder param.</p><div
class="confluence-information-macro
confluence-information-macro-information"><span class="aui-icon aui-icon-small
aui-iconfont-info confluence-information-macro-icon"></span><div
class="confluence-information-macro-body"><p>Read further above about using non
shareable encoders/decoders.</p></div></div><p>The lists of codecs need to be
added to the Camel's registry so they can be resolved when the endpoint is
created.</p><div class="code panel pdl" style="b
order-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-ChannelHandlerFactory lengthDecoder =
ChannelHandlerFactories.newLengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4);
-
-StringDecoder stringDecoder = new StringDecoder();
-registry.bind("length-decoder", lengthDecoder);
-registry.bind("string-decoder", stringDecoder);
-
-LengthFieldPrepender lengthEncoder = new LengthFieldPrepender(4);
-StringEncoder stringEncoder = new StringEncoder();
-registry.bind("length-encoder", lengthEncoder);
-registry.bind("string-encoder", stringEncoder);
-
-List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
-decoders.add(lengthDecoder);
-decoders.add(stringDecoder);
-
-List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
-encoders.add(lengthEncoder);
-encoders.add(stringEncoder);
-
-registry.bind("encoders", encoders);
-registry.bind("decoders", decoders);
-]]></script>
-</div></div>Spring's native collections support can be used to specify the
codec lists in an application context<div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
- <util:list id="decoders"
list-class="java.util.LinkedList">
- <bean
class="org.apache.camel.component.netty.ChannelHandlerFactories"
factory-method="newLengthFieldBasedFrameDecoder">
- <constructor-arg value="1048576"/>
- <constructor-arg value="0"/>
- <constructor-arg value="4"/>
- <constructor-arg value="0"/>
- <constructor-arg value="4"/>
- </bean>
- <bean
class="org.jboss.netty.handler.codec.string.StringDecoder"/>
- </util:list>
-
- <util:list id="encoders"
list-class="java.util.LinkedList">
- <bean
class="org.jboss.netty.handler.codec.frame.LengthFieldPrepender">
- <constructor-arg value="4"/>
- </bean>
- <bean
class="org.jboss.netty.handler.codec.string.StringEncoder"/>
- </util:list>
-
- <bean id="length-encoder"
class="org.jboss.netty.handler.codec.frame.LengthFieldPrepender">
- <constructor-arg value="4"/>
- </bean>
- <bean id="string-encoder"
class="org.jboss.netty.handler.codec.string.StringEncoder"/>
-
- <bean id="length-decoder"
class="org.apache.camel.component.netty.ChannelHandlerFactories"
factory-method="newLengthFieldBasedFrameDecoder">
- <constructor-arg value="1048576"/>
- <constructor-arg value="0"/>
- <constructor-arg value="4"/>
- <constructor-arg value="0"/>
- <constructor-arg value="4"/>
- </bean>
- <bean id="string-decoder"
class="org.jboss.netty.handler.codec.string.StringDecoder"/>
-
-</beans>
-]]></script>
-</div></div>The bean names can then be used in netty endpoint definitions
either as a comma separated list or contained in a List e.g.<div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-
from("direct:multiple-codec").to("netty:tcp://localhost:{{port}}?encoders=#encoders&sync=false");
-
-
from("netty:tcp://localhost:{{port}}?decoders=#length-decoder,#string-decoder&sync=false").to("mock:multiple-codec");
- }
- };
- }
-}
-]]></script>
-</div></div>or via spring.<div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<script class="brush: xml; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
-<camelContext id="multiple-netty-codecs-context"
xmlns="http://camel.apache.org/schema/spring">
- <route>
- <from uri="direct:multiple-codec"/>
- <to
uri="netty:tcp://localhost:5150?encoders=#encoders&amp;sync=false"/>
- </route>
- <route>
- <from
uri="netty:tcp://localhost:5150?decoders=#length-decoder,#string-decoder&amp;sync=false"/>
- <to uri="mock:multiple-codec"/>
- </route>
-</camelContext>
-]]></script>
-</div></div><h3 id="Netty-ClosingChannelWhenComplete">Closing Channel When
Complete</h3><p>When acting as a server you sometimes want to close the channel
when, for example, a client conversion is finished.<br clear="none"> You can do
this by simply setting the endpoint option
<code>disconnect=true</code>.</p><p>However you can also instruct Camel on a
per message basis as follows.<br clear="none"> To instruct Camel to close the
channel, you should add a header with the key
<code>CamelNettyCloseChannelWhenComplete</code> set to a boolean
<code>true</code> value.<br clear="none"> For instance, the example below will
close the channel after it has written the bye message back to the
client:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[
from("netty:tcp://localhost:8080").process(new Processor() {
+</plain-text-body><p>Remember to set <code>needClientAuth=true</code> to
authenticate the client, otherwise <code>SSLSession</code> cannot access
information about the client certificate, and you may get an exception
<code>javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated</code>.
You may also get this exception if the client certificate is expired or not
valid etc.</p><rich-text-body><p>The option <code>sslClientCertHeaders</code>
can be set to <code>true</code> which then enriches the Camel <a shape="rect"
href="message.html">Message</a> with headers having details about the client
certificate. For example the subject name is readily available in the header
<code>CamelNettySSLClientCertSubjectName</code>.</p></rich-text-body><h4
id="Netty-UsingMultipleCodecs">Using Multiple Codecs</h4><p>In certain cases it
may be necessary to add chains of encoders and decoders to the netty pipeline.
To add multpile codecs to a camel netty endpoint the 'encoders' and 'decoders'
uri
parameters should be used. Like the 'encoder' and 'decoder' parameters they
are used to supply references (to lists of ChannelUpstreamHandlers and
ChannelDownstreamHandlers) that should be added to the pipeline. Note that if
encoders is specified then the encoder param will be ignored, similarly for
decoders and the decoder param.</p><rich-text-body><p>Read further above about
using non shareable encoders/decoders.</p></rich-text-body><p>The lists of
codecs need to be added to the Camel's registry so they can be resolved when
the endpoint is
created.<plain-text-body>{snippet:id=registry-beans|lang=java|url=camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/MultipleCodecsTest.java}</plain-text-body>Spring's
native collections support can be used to specify the codec lists in an
application
context<plain-text-body>{snippet:id=registry-beans|lang=xml|url=camel/trunk/components/camel-netty/src/test/resources/org/apache/camel/component/netty/multiple-codecs
.xml}</plain-text-body>The bean names can then be used in netty endpoint
definitions either as a comma separated list or contained in a List
e.g.<plain-text-body>{snippet:id=routes|lang=java|url=camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/MultipleCodecsTest.java}</plain-text-body>or
via
spring.<plain-text-body>{snippet:id=routes|lang=xml|url=camel/trunk/components/camel-netty/src/test/resources/org/apache/camel/component/netty/multiple-codecs.xml}</plain-text-body></p><h3
id="Netty-ClosingChannelWhenComplete">Closing Channel When
Complete</h3><p>When acting as a server you sometimes want to close the channel
when, for example, a client conversion is finished.<br clear="none"> You can do
this by simply setting the endpoint option
<code>disconnect=true</code>.</p><p>However you can also instruct Camel on a
per message basis as follows.<br clear="none"> To instruct Camel to close the
channel, you should add a header with the key <code>CamelNettyClo
seChannelWhenComplete</code> set to a boolean <code>true</code> value.<br
clear="none"> For instance, the example below will close the channel after it
has written the bye message back to the client:</p><plain-text-body>
from("netty:tcp://localhost:8080").process(new Processor() {
public void process(Exchange exchange) throws Exception {
String body = exchange.getIn().getBody(String.class);
- exchange.getOut().setBody("Bye " + body);
+ exchange.getOut().setBody("Bye " + body);
// some condition which determines if we should close
if (close) {
exchange.getOut().setHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE,
true);
}
}
});
-]]></script>
-</div></div><h3
id="Netty-Addingcustomchannelpipelinefactoriestogaincompletecontroloveracreatedpipeline">Adding
custom channel pipeline factories to gain complete control over a created
pipeline</h3><p><strong>Available as of Camel 2.5</strong></p><p>Custom channel
pipelines provide complete control to the user over the handler/interceptor
chain by inserting custom handler(s), encoder(s) & decoders without having
to specify them in the Netty Endpoint URL in a very simple way.</p><p>In order
to add a custom pipeline, a custom channel pipeline factory must be created and
registered with the context via the context registry (JNDIRegistry,or the
camel-spring ApplicationContextRegistry etc).</p><p>A custom pipeline factory
must be constructed as follows</p><ul><li>A Producer linked channel pipeline
factory must extend the abstract class
<code>ClientPipelineFactory</code>.</li><li>A Consumer linked channel pipeline
factory must extend the abstract class <code>ServerPipelineFactory</co
de>.</li><li>The classes should override the getPipeline() method in order to
insert custom handler(s), encoder(s) and decoder(s). Not overriding the
getPipeline() method creates a pipeline with no handlers, encoders or decoders
wired to the pipeline.</li></ul><p>The example below shows how ServerChannel
Pipeline factory may be created</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeHeader panelHeader pdl"
style="border-bottom-width: 1px;"><b>Using custom pipeline
factory</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[public class
SampleServerChannelPipelineFactory extends ServerPipelineFactory {
+</plain-text-body><h3
id="Netty-Addingcustomchannelpipelinefactoriestogaincompletecontroloveracreatedpipeline">Adding
custom channel pipeline factories to gain complete control over a created
pipeline</h3><p><strong>Available as of Camel 2.5</strong></p><p>Custom channel
pipelines provide complete control to the user over the handler/interceptor
chain by inserting custom handler(s), encoder(s) & decoders without having
to specify them in the Netty Endpoint URL in a very simple way.</p><p>In order
to add a custom pipeline, a custom channel pipeline factory must be created and
registered with the context via the context registry (JNDIRegistry,or the
camel-spring ApplicationContextRegistry etc).</p><p>A custom pipeline factory
must be constructed as follows</p><ul><li>A Producer linked channel pipeline
factory must extend the abstract class
<code>ClientPipelineFactory</code>.</li><li>A Consumer linked channel pipeline
factory must extend the abstract class <code>ServerPipelineFacto
ry</code>.</li><li>The classes should override the getPipeline() method in
order to insert custom handler(s), encoder(s) and decoder(s). Not overriding
the getPipeline() method creates a pipeline with no handlers, encoders or
decoders wired to the pipeline.</li></ul><p>The example below shows how
ServerChannel Pipeline factory may be created</p><parameter
ac:name="title">Using custom pipeline
factory</parameter><plain-text-body>public class
SampleServerChannelPipelineFactory extends ServerPipelineFactory {
private int maxLineSize = 1024;
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline channelPipeline = Channels.pipeline();
- channelPipeline.addLast("encoder-SD", new
StringEncoder(CharsetUtil.UTF_8));
- channelPipeline.addLast("decoder-DELIM", new
DelimiterBasedFrameDecoder(maxLineSize, true, Delimiters.lineDelimiter()));
- channelPipeline.addLast("decoder-SD", new
StringDecoder(CharsetUtil.UTF_8));
+ channelPipeline.addLast("encoder-SD", new
StringEncoder(CharsetUtil.UTF_8));
+ channelPipeline.addLast("decoder-DELIM", new
DelimiterBasedFrameDecoder(maxLineSize, true, Delimiters.lineDelimiter()));
+ channelPipeline.addLast("decoder-SD", new
StringDecoder(CharsetUtil.UTF_8));
// here we add the default Camel ServerChannelHandler for the
consumer, to allow Camel to route the message etc.
- channelPipeline.addLast("handler", new
ServerChannelHandler(consumer));
+ channelPipeline.addLast("handler", new ServerChannelHandler(consumer));
return channelPipeline;
}
}
-]]></script>
-</div></div><p>The custom channel pipeline factory can then be added to the
registry and instantiated/utilized on a camel route in the following
way</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default"
type="syntaxhighlighter"><![CDATA[Registry registry =
camelContext.getRegistry();
+</plain-text-body><p>The custom channel pipeline factory can then be added to
the registry and instantiated/utilized on a camel route in the following
way</p><plain-text-body>Registry registry = camelContext.getRegistry();
serverPipelineFactory = new TestServerChannelPipelineFactory();
-registry.bind("spf", serverPipelineFactory);
+registry.bind("spf", serverPipelineFactory);
context.addRoutes(new RouteBuilder() {
public void configure() {
String netty_ssl_endpoint =
- "netty:tcp://localhost:5150?serverPipelineFactory=#spf"
+ "netty:tcp://localhost:5150?serverPipelineFactory=#spf"
String return_string =
- "When You Go Home, Tell Them Of Us And Say,"
- + "For Your Tomorrow, We Gave Our Today.";
+ "When You Go Home, Tell Them Of Us And Say,"
+ + "For Your Tomorrow, We Gave Our Today.";
from(netty_ssl_endpoint)
.process(new Processor() {
@@ -323,34 +199,26 @@ context.addRoutes(new RouteBuilder() {
}
});
-]]></script>
[... 43 lines stripped ...]