camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claus Ibsen (Confluence)" <conflue...@apache.org>
Subject [CONF] Apache Camel > Netty HTTP
Date Thu, 27 Jun 2013 15:36:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/en/2176/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/Netty+HTTP">Netty
HTTP</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (2)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{urlDecodeHeaders}} | {{true}}
| If this option is enabled, then during binding from Netty to Camel [Message] then the header
values will be URL decoded (eg %20 will be a space character. Notice this option is used by
the default {{org.apache.camel.component.netty.http.NettyHttpBinding}} and therefore if you
implement a custom {{org.apache.camel.component.netty.http.NettyHttpBinding}} then you would
need to decode the headers accordingly to this option. | <br>| {{nettySharedHttpServer}}
| {{null}} | To use a shared [Netty HTTP] server. See [Netty HTTP Server Example] for more
details. | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
{{disableStreamCache}} | {{false}} | Determines whether or not the raw input stream from Netty
{{HttpRequest#getContent()}} is cached or not (Camel will read the stream into a in light-weight
memory based Stream caching) cache. By default Camel will cache the Netty input stream to
support reading it multiple times to ensure it Camel can retrieve all data from the stream.
However you can set this option to {{true}} when you for example need to access the raw stream,
such as streaming it directly to a file or other persistent store. Mind that if you enable
this option, then you cannot read the Netty stream multiple times out of the box, and you
would need manually to reset the reader index on the Netty raw stream. | <br></td></tr>
            <tr><td class="diff-unchanged" >{div} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{CamelHttpQuery}} | {{String}}
| Any query parameters, such as {{foo=bar&amp;beer=yes}} | <br>| {{CamelHttpPath}}
| {{String}} | Additional context-path. This value is empty if the client called the context-path
{{/myapp}}. If the client calls {{/myapp/mystuff}}, then this header value is {{/mystuff}}.
In other words its the value after the context-path configured on the route endpoint. | <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">|
{{CamelHttpCharacterEncoding}} | {{String}} | The charset from the content-type header. |
<br></td></tr>
            <tr><td class="diff-unchanged" >| {{Content-Type}} | {{String}} |
The content type if provided. For example: {{text/plain; charset=&quot;UTF-8&quot;}}.
| <br>{div} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="NettyHTTP-NettyHTTPComponent"></a>Netty HTTP Component</h2>
<p><b>Available as of Camel 2.12</b></p>

<p>The <b>netty-http</b> component is an extension to <a href="/confluence/display/CAMEL/Netty"
title="Netty">Netty</a> component to facilitiate HTTP transport with <a href="/confluence/display/CAMEL/Netty"
title="Netty">Netty</a>.</p>

<p>This camel component supports both producer and consumer endpoints.</p>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Stream</b><br
/>Netty is stream based, which means the input it receives is submitted to Camel as a stream.
That means you will only be able to read the content of the stream <b>once</b>.<br/>
If you find a situation where the message body appears to be empty or you need to access the
data multiple times (eg: doing multicasting, or redelivery error handling)<br/>
you should use <a href="/confluence/display/CAMEL/Stream+caching" title="Stream caching">Stream
caching</a> or convert the message body to a <tt>String</tt> which is safe
to be re-read multiple times.</td></tr></table></div>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
    &lt;artifactId&gt;camel-netty-http&lt;/artifactId&gt;
    &lt;version&gt;x.x.x&lt;/version&gt;
    &lt;!-- use the same version as your Camel core version --&gt;
&lt;/dependency&gt;
</pre>
</div></div>

<h3><a name="NettyHTTP-URIformat"></a>URI format</h3>

<p>The URI scheme for a netty component is as follows</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
netty-http:http://localhost:8080[?options]
</pre>
</div></div>

<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt></p>

<h3><a name="NettyHTTP-HTTPOptions"></a>HTTP Options</h3>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>A lot more
options</b><br /><b>Important:</b> This component inherits all the
options from <a href="/confluence/display/CAMEL/Netty" title="Netty">Netty</a>.
So make sure to look at the <a href="/confluence/display/CAMEL/Netty" title="Netty">Netty</a>
documentation as well.<br/>
Notice that some options from <a href="/confluence/display/CAMEL/Netty" title="Netty">Netty</a>
is not applicable when using this <a href="/confluence/display/CAMEL/Netty+HTTP" title="Netty
HTTP">Netty HTTP</a> component, such as options related to UDP transport.</td></tr></table></div>

<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>chunked</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> Allow using chunked transfer if the client supports it from
the HTTP headers. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>compression</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> Allow using gzip/deflate for compression if the client supports
it from the HTTP headers. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>headerFilterStrategy</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> To use a custom  <tt>org.apache.camel.spi.HeaderFilterStrategy</tt>
to filter headers. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>httpMethodRestrict</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> To disable HTTP methods on the Netty HTTP consumer. You can
specify multiple separated by comma. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>mapHeaders</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> If this option is enabled, then during binding from Netty
to Camel <a href="/confluence/display/CAMEL/Message" title="Message">Message</a>
then the headers will be mapped as well (eg added as header to the Camel <a href="/confluence/display/CAMEL/Message"
title="Message">Message</a> as well). You can turn off this option to disable this.
The headers can still be accessed from the <tt>org.apache.camel.component.netty.http.NettyHttpMessage</tt>
message with the method <tt>getHttpRequest()</tt> that returns the Netty HTTP
request <tt>org.jboss.netty.handler.codec.http.HttpRequest</tt> instance. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>matchOnUriPrefix</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> Whether or not Camel should try to find a target consumer
by matching the URI prefix if no exact match is found. See further below for more details.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>nettyHttpBinding</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> To use a custom <tt>org.apache.camel.component.netty.http.NettyHttpBinding</tt>
for binding to/from Netty and Camel Message API. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>bridgeEndpoint</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> If the option is <tt>true</tt>, the producer will
ignore the <tt>Exchange.HTTP_URI</tt> header, and use the endpoint's URI for request.
You may also set the <tt>throwExceptionOnFailure</tt> to be <tt>false</tt>
to let the producer send all the fault response back. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>throwExceptionOnFailure</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> Option to disable throwing the <tt>HttpOperationFailedException</tt>
in case of failed responses from the remote server. This allows you to get all responses regardles
of the HTTP status code. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>traceEnabled</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> Specifies whether to enable HTTP TRACE for this Netty HTTP
consumer. By default TRACE is turned off. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>transferException</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> If enabled and an <a href="/confluence/display/CAMEL/Exchange"
title="Exchange">Exchange</a> failed processing on the consumer side, and if the
caused Exception was send back serialized in the response as a <tt>application/x-java-serialized-object</tt>
content type. On the producer side the exception will be deserialized and thrown as is, instead
of the <tt>HttpOperationFailedException</tt>. The caused exception is required
to be serialized. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>urlDecodeHeaders</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> If this option is enabled, then during binding from Netty
to Camel <a href="/confluence/display/CAMEL/Message" title="Message">Message</a>
then the header values will be URL decoded (eg %20 will be a space character. Notice this
option is used by the default <tt>org.apache.camel.component.netty.http.NettyHttpBinding</tt>
and therefore if you implement a custom <tt>org.apache.camel.component.netty.http.NettyHttpBinding</tt>
then you would need to decode the headers accordingly to this option. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>nettySharedHttpServer</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> To use a shared <a href="/confluence/display/CAMEL/Netty+HTTP"
title="Netty HTTP">Netty HTTP</a> server. See <a href="/confluence/display/CAMEL/Netty+HTTP+Server+Example"
title="Netty HTTP Server Example">Netty HTTP Server Example</a> for more details.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>disableStreamCache</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> Determines whether or not the raw input stream from Netty
<tt>HttpRequest#getContent()</tt> is cached or not (Camel will read the stream
into a in light-weight memory based Stream caching) cache. By default Camel will cache the
Netty input stream to support reading it multiple times to ensure it Camel can retrieve all
data from the stream. However you can set this option to <tt>true</tt> when you
for example need to access the raw stream, such as streaming it directly to a file or other
persistent store. Mind that if you enable this option, then you cannot read the Netty stream
multiple times out of the box, and you would need manually to reset the reader index on the
Netty raw stream. </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="NettyHTTP-MessageHeaders"></a>Message Headers</h3>

<p>The following headers can be used on the producer to control the HTTP request.</p>

<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHttpMethod</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> Allow to control what HTTP method to use such as GET, POST,
TRACE etc. The type can also be a <tt>org.jboss.netty.handler.codec.http.HttpMethod</tt>
instance. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHttpQuery</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> Allows to provide URI query parameters as a <tt>String</tt>
value that overrides the endpoint configuration. Separate multiple parameters using the &amp;
sign. For example: <tt>foo=bar&amp;beer=yes</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>Content-Type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> To set the content-type of the HTTP body. For example: <tt>text/plain;
charset="UTF-8"</tt>. </td>
</tr>
</tbody></table>
</div>
</div>

<p>The following headers is provided as meta-data when a route starts from an <a
href="/confluence/display/CAMEL/Netty+HTTP" title="Netty HTTP">Netty HTTP</a> endpoint:</p>

<p>The description in the table takes offset in a route having: <tt>from("netty-http:http:0.0.0.0:8080/myapp")...</tt>
</p>

<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHttpMethod</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The HTTP method used, such as GET, POST, TRACE etc. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHttpUrl</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The URL including protocol, host and port, etc: <div class="code
panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">http://0.0.0.0:8080/myapp</pre>
</div></div> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHttpUri</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The URI without protocol, host and port, etc: <div class="code
panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">/myapp</pre>
</div></div> </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHttpQuery</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> Any query parameters, such as <tt>foo=bar&amp;beer=yes</tt>
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHttpPath</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> Additional context-path. This value is empty if the client
called the context-path <tt>/myapp</tt>. If the client calls <tt>/myapp/mystuff</tt>,
then this header value is <tt>/mystuff</tt>. In other words its the value after
the context-path configured on the route endpoint. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>CamelHttpCharacterEncoding</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The charset from the content-type header. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>Content-Type</tt> </td>
<td class='confluenceTd'> <tt>String</tt> </td>
<td class='confluenceTd'> The content type if provided. For example: <tt>text/plain;
charset="UTF-8"</tt>. </td>
</tr>
</tbody></table>
</div>
</div>


<h3><a name="NettyHTTP-AccesstoNettytypes"></a>Access to Netty types</h3>

<p>This component uses the <tt>org.apache.camel.component.netty.http.NettyHttpMessage</tt>
as the message implementation on the <a href="/confluence/display/CAMEL/Exchange" title="Exchange">Exchange</a>.
This allows end users to get access to the original Netty request/response instances if needed,
as shown below:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
org.jboss.netty.handler.codec.http.HttpRequest request = exchange.getIn(NettyHttpMessage.class).getHttpRequest();
</pre>
</div></div>

<h3><a name="NettyHTTP-Examples"></a>Examples</h3>

<p>In the route below we use <a href="/confluence/display/CAMEL/Netty+HTTP" title="Netty
HTTP">Netty HTTP</a> as a HTTP server, which returns back a hardcoded "Bye World"
message. </p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
    from("netty-http:http://0.0.0.0:8080/foo")
      .transform().constant("Bye World");
</pre>
</div></div>

<p>And we can call this HTTP server using Camel also, with the <a href="/confluence/display/CAMEL/ProducerTemplate"
title="ProducerTemplate">ProducerTemplate</a> as shown below:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
    String out = template.requestBody("netty-http:http://localhost:8080/foo", "Hello World",
String.class);
    System.out.println(out);
</pre>
</div></div>

<p>And we get back "Bye World" as the output.</p>

<h3><a name="NettyHTTP-HowdoIletNettymatchwildcards"></a>How do I let Netty
match wildcards</h3>

<p>By default <a href="/confluence/display/CAMEL/Netty+HTTP" title="Netty HTTP">Netty
HTTP</a> will only match on exact uri's. But you can instruct Netty to match prefixes.
For example</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
from("netty-http:http://0.0.0.0:8123/foo").to("mock:foo");
</pre>
</div></div>

<p>In the route above <a href="/confluence/display/CAMEL/Netty+HTTP" title="Netty
HTTP">Netty HTTP</a> will only match if the uri is an exact match, so it will match
if you enter<br/>
<tt><a href="http://0.0.0.0:8123/foo" class="external-link" rel="nofollow">http://0.0.0.0:8123/foo</a></tt>
but not match if you do <tt><a href="http://0.0.0.0:8123/foo/bar" class="external-link"
rel="nofollow">http://0.0.0.0:8123/foo/bar</a></tt>.</p>

<p>So if you want to enable wildcard matching you do as follows: </p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
from("netty-http:http://0.0.0.0:8123/foo?matchOnUriPrefix=true").to("mock:foo");
</pre>
</div></div>
<p>So now Netty matches any endpoints with starts with <tt>foo</tt>.</p>

<p>To match <b>any</b> endpoint you can do:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
from("netty-http:http://0.0.0.0:8123?matchOnUriPrefix=true").to("mock:foo");
</pre>
</div></div>

<h3><a name="NettyHTTP-Usingmultiplerouteswithsameport"></a>Using multiple
routes with same port</h3>

<p>In the same <a href="/confluence/display/CAMEL/CamelContext" title="CamelContext">CamelContext</a>
you can have multiple routes from <a href="/confluence/display/CAMEL/Netty+HTTP" title="Netty
HTTP">Netty HTTP</a> that shares the same port (eg a <tt>org.jboss.netty.bootstrap.ServerBootstrap</tt>
instance). Doing this requires a number of bootstrap options to be identical in the routes,
as the routes will share the same <tt>org.jboss.netty.bootstrap.ServerBootstrap</tt>
instance. The instance will be configured with the options from the first route created.</p>

<p>The options the routes must be identical configured is all the options defined in
the <tt>org.apache.camel.component.netty.NettyServerBootstrapConfiguration</tt>
configuration class. If you have configured another route with different options, Camel will
throw an exception on startup, indicating the options is not identical. To mitigate this ensure
all options is identical.</p>

<p>Here is an example with two routes that share the same port.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Two routes sharing the same port</b></div><div
class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
from("netty-http:http://0.0.0.0:{{port}}/foo")
  .to("mock:foo")
  .transform().constant("Bye World");

from("netty-http:http://0.0.0.0:{{port}}/bar")
  .to("mock:bar")
  .transform().constant("Bye Camel");
</pre>
</div></div>

<p>And here is an example of a mis configured 2nd route that do not have identical <tt>org.apache.camel.component.netty.NettyServerBootstrapConfiguration</tt>
option as the 1st route. This will cause Camel to fail on startup.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader panelHeader"
style="border-bottom-width: 1px;"><b>Two routes sharing the same port, but the 2nd
route is misconfigured and will fail on starting</b></div><div class="codeContent
panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
from("netty-http:http://0.0.0.0:{{port}}/foo")
  .to("mock:foo")
  .transform().constant("Bye World");

// we cannot have a 2nd route on same port with SSL enabled, when the 1st route is NOT
from("netty-http:http://0.0.0.0:{{port}}/bar?ssl=true")
  .to("mock:bar")
  .transform().constant("Bye Camel");
</pre>
</div></div>

<h4><a name="NettyHTTP-Reusingsameserverbootstrapconfigurationwithmultipleroutes"></a>Reusing
same server bootstrap configuration with multiple routes</h4>

<p>By configuring the common server bootstrap option in an single instance of a <tt>org.apache.camel.component.netty.NettyServerBootstrapConfiguration</tt>
type, we can use the <tt>bootstrapConfiguration</tt> option on the <a href="/confluence/display/CAMEL/Netty+HTTP"
title="Netty HTTP">Netty HTTP</a> consumers to refer and reuse the same options across
all consumers.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;bean id="nettyHttpBootstrapOptions" class="org.apache.camel.component.netty.NettyServerBootstrapConfiguration"&gt;
  &lt;property name="backlog" value="200"/&gt;
  &lt;property name="connectionTimeout" value="20000"/&gt;
  &lt;property name="workerCount" value="16"/&gt;
&lt;/bean&gt;
</pre>
</div></div>

<p>And in the routes you refer to this option as shown below</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;route&gt;
  &lt;from uri="netty-http:http://0.0.0.0:{{port}}/foo?bootstrapConfiguration=#nettyHttpBootstrapOptions"/&gt;
  ...
&lt;/route&gt;

&lt;route&gt;
  &lt;from uri="netty-http:http://0.0.0.0:{{port}}/bar?bootstrapConfiguration=#nettyHttpBootstrapOptions"/&gt;
  ...
&lt;/route&gt;

&lt;route&gt;
  &lt;from uri="netty-http:http://0.0.0.0:{{port}}/beer?bootstrapConfiguration=#nettyHttpBootstrapOptions"/&gt;
  ...
&lt;/route&gt;
</pre>
</div></div>

<h4><a name="NettyHTTP-ReusingsameserverbootstrapconfigurationwithmultipleroutesacrossmultiplebundlesinOSGicontainer"></a>Reusing
same server bootstrap configuration with multiple routes across multiple bundles in OSGi container</h4>

<p>See the <a href="/confluence/display/CAMEL/Netty+HTTP+Server+Example" title="Netty
HTTP Server Example">Netty HTTP Server Example</a> for more details and example how
to do that.</p>


<h3><a name="NettyHTTP-SeeAlso"></a>See Also</h3>
<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring
Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting
Started</a></li>
</ul>

<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/Netty" title="Netty">Netty</a></li>
	<li><a href="/confluence/display/CAMEL/Netty+HTTP+Server+Example" title="Netty HTTP
Server Example">Netty HTTP Server Example</a></li>
	<li><a href="/confluence/display/CAMEL/Jetty" title="Jetty">Jetty</a></li>
</ul>

    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=CAMEL">Stop
watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://cwiki.apache.org/confluence/users/editmyemailsettings.action">Change
email notification preferences</a>
</div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Netty+HTTP">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=31820132&revisedVersion=16&originalVersion=15">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/Netty+HTTP?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message