camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > MINA
Date Thu, 08 Oct 2009 06:23:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/CAMEL/MINA">MINA</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="MINA-MINAComponent"></a>MINA Component</h2>

<p>The <b>mina:</b> component is a transport for working with <a href="http://mina.apache.org/"
rel="nofollow">Apache MINA</a></p>

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

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
mina:tcp:<span class="code-comment">//hostname[:port][?options]
</span>mina:udp:<span class="code-comment">//hostname[:port][?options]
</span>mina:multicast:<span class="code-comment">//hostname[:port][?options]
</span>mina:vm:<span class="code-comment">//hostname[:port][?options]</span>
</pre>
</div></div>
<p>From Camel 1.3 onwards you can specify a codec in the <a href="/confluence/display/CAMEL/Registry"
title="Registry">Registry</a> using the <b>codec</b> option. If you are
using TCP and no codec is specified then the <tt>textline</tt> flag is used to
determine if text line based codec or object serialization should be used instead. By default
the object serialization is used.</p>

<p>For UDP/Multicast if no codec is specified the default uses a basic <tt>ByteBuffer</tt>
based codec.</p>

<p>Multicast also has a shorthand notation <b>mcast</b>.</p>

<p>The VM protocol is used as a direct forwarding mechanism in the same JVM. See the
<a href="http://mina.apache.org/report/1.1/apidocs/org/apache/mina/transport/vmpipe/package-summary.html"
rel="nofollow">MINA VM-Pipe API documentation</a> for details.</p>

<p>A Mina producer has a default timeout value of 30 seconds, while it waits for a response
from the remote server.</p>

<p>In normal use, <tt>camel-mina</tt> only supports marshalling the body
content&mdash;message headers and exchange properties are not sent.<br/>
However, the option, <b>transferExchange</b>, does allow you to transfer the exchange
itself over the wire. See options below.</p>

<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="MINA-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option</th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>codec</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> As of 1.3, you can refer to a named <tt>ProtocolCodecFactory</tt>
instance in your <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>
such as your Spring <tt>ApplicationContext</tt>, which is then used for the marshalling.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>codec</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> <b>Camel 2.0:</b> You must use the <tt>&#35;</tt>
notation to look up your codec in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>.
For example, use <tt>#myCodec</tt> to look up a bean with the <tt>id</tt>
value, <tt>myCodec</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>textline</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> Only used for TCP. If no codec is specified, you can use this
flag in 1.3 or later to indicate a text line based codec; if not specified or the value is
<tt>false</tt>, then Object Serialization is assumed over TCP. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>textlineDelimiter</tt> </td>
<td class='confluenceTd'> <tt>DEFAULT</tt> </td>
<td class='confluenceTd'> <b>Camel 1.5.1/2.0</b> Only used for TCP and if
<b>textline=true</b>. Sets the text line delimiter to use. Possible values are:
<tt>DEFAULT</tt>, <tt>AUTO</tt>, <tt>WINDOWS</tt>, <tt>UNIX</tt>
or <tt>MAC</tt>. If none provided, Camel will use <tt>DEFAULT</tt>.
This delimiter is used to mark the end of text. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>sync</tt> </td>
<td class='confluenceTd'> <tt>false</tt>/<tt>true</tt> </td>
<td class='confluenceTd'> As of 1.3, you can configure the exchange pattern to be either
InOnly (default) or InOut. Setting <tt>sync=true</tt> means a synchronous exchange
(InOut), where the client can read the response from MINA (the exchange Out message). The
default value has changed in Camel 1.5 to <tt>true</tt>. In older releases, the
default value is <tt>false</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>lazySessionCreation</tt> </td>
<td class='confluenceTd'> <em>See description</em> </td>
<td class='confluenceTd'> As of 1.3, sessions can be lazily created to avoid exceptions,
if the remote server is not up and running when the Camel producer is started. From Camel
2.0 onwards, the default is <tt>true</tt>. In Camel 1.x, the default is <tt>false</tt>.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>timeout</tt> </td>
<td class='confluenceTd'> <tt>30000</tt> </td>
<td class='confluenceTd'> As of 1.3, you can configure the timeout that specifies how
long to wait for a response from a remote server. The timeout unit is in milliseconds, so
60000 is 60 seconds. The timeout is only used for Mina producer. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>encoding</tt> </td>
<td class='confluenceTd'> <em>JVM Default</em> </td>
<td class='confluenceTd'> As of 1.3, you can configure the encoding (a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/nio/charset/Charset.html"
rel="nofollow">charset name</a>) to use for the TCP textline codec and the UDP protocol.
If not provided, Camel will use the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/nio/charset/Charset.html#defaultCharset()"
rel="nofollow">JVM default Charset</a>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>transferExchange</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> Only used for TCP. As of 1.3, 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 <em>serializable</em>. Camel will exclude any
non-serializable objects and log it at <tt>WARN</tt> level. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>minaLogger</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> As of 1.3, you can enable the Apache MINA logging filter.
Apache MINA uses <tt>slf4j</tt> logging at <tt>INFO</tt> level to
log all input and output. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>filters</tt> </td>
<td class='confluenceTd'> <tt>null</tt> </td>
<td class='confluenceTd'> As of 2.0, you can set a list of <a href="http://mina.apache.org/iofilter.html"
rel="nofollow">Mina IoFilters</a> to register. The type must be <tt>List&lt;org.apache.mina.common.IoFilter&gt;</tt>.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>encoderMaxLineLength</tt> </td>
<td class='confluenceTd'> <tt>-1</tt> </td>
<td class='confluenceTd'> As of 2.1, you can set the textline protocol encoder max line
length. By default the default value of Mina itself is used which are <tt>Integer.MAX_VALUE</tt>.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>decorderMaxLineLength</tt> </td>
<td class='confluenceTd'> <tt>-1</tt> </td>
<td class='confluenceTd'> As of 2.1, you can set the textline protocol decoder max line
length. By default the default value of Mina itself is used which are 1024. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>producerPoolSize</tt> </td>
<td class='confluenceTd'> 16 </td>
<td class='confluenceTd'> <b>1.6.2 (only in 1.6.x)</b>: The TCP producer
is now thread safe and supports concurrency much better. This option allows you to configure
the number of threads in its thread pool for concurrent producers. <b>Note:</b>
Camel 2.0 have a pooled service which ensured it was already thread safe and supported concurrency
already. So this is a special patch for 1.6.x. </td>
</tr>
</tbody></table>

<h3><a name="MINA-Defaultbehaviorchanged"></a>Default behavior changed</h3>
<p>In Camel 2.0 the <b>codec</b> option must use <tt>&#35;</tt>
notation for lookup of the codec bean in the <a href="/confluence/display/CAMEL/Registry"
title="Registry">Registry</a>.<br/>
In Camel 2.0 the <b>lazySessionCreation</b> option now defaults to <tt>true</tt>.</p>

<p>In Camel 1.5 the <tt>sync</tt> option has changed its default value from
<tt>false</tt> to <tt>true</tt>, as we felt it was confusing for end-users
when they used <a href="/confluence/display/CAMEL/MINA" title="MINA">MINA</a>
to call remote servers and Camel wouldn't wait for the response.</p>

<p>In Camel 1.4 or later <tt>codec=textline</tt> is no longer supported.
Use the <tt>textline=true</tt> option instead.</p>

<h3><a name="MINA-Usingacustomcodec"></a>Using a custom codec</h3>
<p>See the <a href="http://mina.apache.org/tutorial-on-protocolcodecfilter.html"
rel="nofollow">Mina documentation</a> how to write your own codec. To use your custom
codec with <tt>camel-mina</tt>, you should register your codec in the <a href="/confluence/display/CAMEL/Registry"
title="Registry">Registry</a>; for example, by creating a bean in the Spring XML
file. Then use the <tt>codec</tt> option to specify the bean ID of your codec.
See <a href="/confluence/display/CAMEL/HL7" title="HL7">HL7</a> that has a custom
codec.</p>

<h3><a name="MINA-Samplewithsync%3Dfalse"></a>Sample with sync=false</h3>

<p>In this sample, Camel exposes a service that listens for TCP connections on port
6200. We use the <b>textline</b> codec. In our route, we create a Mina consumer
endpoint that listens on port 6200:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">from(<span class="code-quote">"mina:tcp:<span class="code-comment">//localhost:6200?textline=<span
class="code-keyword">true</span>&amp;sync=<span class="code-keyword">false</span>"</span>).to(<span
class="code-quote">"mock:result"</span>);</span>
</pre>
</div></div>

<p>As the sample is part of a unit test, we test it by sending some data to it on port
6200. </p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">MockEndpoint mock = getMockEndpoint(<span class="code-quote">"mock:result"</span>);
mock.expectedBodiesReceived(<span class="code-quote">"Hello World"</span>);

template.sendBody(<span class="code-quote">"mina:tcp:<span class="code-comment">//localhost:6200?textline=<span
class="code-keyword">true</span>&amp;sync=<span class="code-keyword">false</span>"</span>,
<span class="code-quote">"Hello World"</span>);
</span>
assertMockEndpointsSatisfied();
</pre>
</div></div>

<h3><a name="MINA-Samplewithsync%3Dtrue"></a>Sample with sync=true</h3>

<p>In the next sample, we have a more common use case where we expose a TCP service
on port 6201 also use the textline codec. However, this time we want to return a response,
so we set the <tt>sync</tt> option to <tt>true</tt> on the consumer.
</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">from(<span class="code-quote">"mina:tcp:<span class="code-comment">//localhost:6201?textline=<span
class="code-keyword">true</span>&amp;sync=<span class="code-keyword">true</span>"</span>).process(<span
class="code-keyword">new</span> Processor() {
</span>    <span class="code-keyword">public</span> void process(Exchange
exchange) <span class="code-keyword">throws</span> Exception {
        <span class="code-object">String</span> body = exchange.getIn().getBody(<span
class="code-object">String</span>.class);
        exchange.getOut().setBody(<span class="code-quote">"Bye "</span> + body);
    }
});
</pre>
</div></div>

<p>Then we test the sample by sending some data and retrieving the response using the
<tt>template.requestBody()</tt> method. As we know the response is a <tt>String</tt>,
we cast it to <tt>String</tt> and can assert that the response is, in fact, something
we have dynamically set in our processor code logic.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-object">String</span> response
= (<span class="code-object">String</span>)template.requestBody(<span class="code-quote">"mina:tcp:<span
class="code-comment">//localhost:6201?textline=<span class="code-keyword">true</span>&amp;sync=<span
class="code-keyword">true</span>"</span>, <span class="code-quote">"World"</span>);
</span>assertEquals(<span class="code-quote">"Bye World"</span>, response);
</pre>
</div></div>

<h3><a name="MINA-SamplewithSpringDSL"></a>Sample with Spring DSL</h3>
<p>Spring DSL can, of course, also be used for <a href="/confluence/display/CAMEL/MINA"
title="MINA">MINA</a>. In the sample below we expose a TCP server on port 5555:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
   <span class="code-tag">&lt;route&gt;</span>
     <span class="code-tag">&lt;from uri=<span class="code-quote">"mina:tcp://localhost:5555?textline=true"</span>/&gt;</span>
     <span class="code-tag">&lt;to uri=<span class="code-quote">"bean:myTCPOrderHandler"</span>/&gt;</span>
  <span class="code-tag">&lt;/route&gt;</span>
</pre>
</div></div>

<p>In the route above, we expose a TCP server on port 5555 using the textline codec.
We let the Spring bean with ID, <tt>myTCPOrderHandler</tt>, handle the request
and return a reply. For instance, the handler bean could be implemented as follows:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
    <span class="code-keyword">public</span> <span class="code-object">String</span>
handleOrder(<span class="code-object">String</span> payload) {
        ...
        <span class="code-keyword">return</span> <span class="code-quote">"Order:
OK"</span>
   }
</pre>
</div></div>

<h3><a name="MINA-ConfiguringMinaendpointsusingSpringbeanstyle"></a>Configuring
Mina endpoints using Spring bean style</h3>
<p><b>Available as of Camel 2.0</b></p>

<p>Configuration of Mina endpoints is now possible using regular Spring bean style configuration
in the Spring DSL.</p>

<p>However, in the underlying Apache Mina toolkit, it is relatively difficult to set
up the acceptor and the connector, because you can <em>not</em> use simple setters.
To resolve this difficulty, we leverage the <tt>MinaComponent</tt> as a Spring
factory bean to configure this for us. If you really need to configure this yourself, there
are setters on the <tt>MinaEndpoint</tt> to set these when needed.</p>

<p>The sample below shows the factory approach:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">&lt;!-- Creating mina endpoints is a bit complex so we reuse
MinaComponnet
     as a factory bean to create our endpoint, this is the easiest to do --&gt;
<span class="code-tag">&lt;bean id=<span class="code-quote">"myMinaFactory"</span>
class=<span class="code-quote">"org.apache.camel.component.mina.MinaComponent"</span>&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- we must provide
a camel context so we refer to it by its id --&gt;</span></span>
    <span class="code-tag">&lt;constructor-arg index=<span class="code-quote">"0"</span>
ref=<span class="code-quote">"myCamel"</span>/&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>

&lt;!-- This is our mina endpoint configured with spring, we will use the factory above
     to create it for us. The goal is to invoke the createEndpoint method with the
     mina configuration parameter we defined using the constructor-arg option --&gt;
&lt;bean id=<span class="code-quote">"myMinaEndpoint"</span>
      factory-bean=<span class="code-quote">"myMinaFactory"</span>
      factory-method=<span class="code-quote">"createEndpoint"</span>&gt;
    <span class="code-tag"><span class="code-comment">&lt;!-- and here we
can pass it our configuration --&gt;</span></span>
    <span class="code-tag">&lt;constructor-arg index=<span class="code-quote">"0"</span>
ref=<span class="code-quote">"myMinaConfig"</span>/&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>

<span class="code-tag"><span class="code-comment">&lt;!-- this is our mina
configuration with plain properties --&gt;</span></span>
<span class="code-tag">&lt;bean id=<span class="code-quote">"myMinaConfig"</span>
class=<span class="code-quote">"org.apache.camel.component.mina.MinaConfiguration"</span>&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"protocol"</span>
value=<span class="code-quote">"tcp"</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"host"</span>
value=<span class="code-quote">"localhost"</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"port"</span>
value=<span class="code-quote">"1234"</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"sync"</span>
value=<span class="code-quote">"false"</span>/&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>
</pre>
</div></div>

<p>And then we can refer to our endpoint directly in the route, as follows:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;route&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- here we route
from or mina endpoint we have defined above --&gt;</span></span>
    <span class="code-tag">&lt;from ref=<span class="code-quote">"myMinaEndpoint"</span>/&gt;</span>
    <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:result"</span>/&gt;</span>
<span class="code-tag">&lt;/route&gt;</span>
</pre>
</div></div>

<h3><a name="MINA-ClosingSessionWhenComplete"></a>Closing Session When Complete</h3>
<p><b>Available as of Camel 1.6.1</b></p>

<p>When acting as a server you sometimes want to close the session when, for example,
a client conversion is finished. To instruct Camel to close the session, you should add a
header with the key <tt>CamelMinaCloseSessionWhenComplete</tt> set to a boolean
<tt>true</tt> value.</p>

<p>For instance, the example below will close the session after it has written the <tt>bye</tt>
message back to the client:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
        from(<span class="code-quote">"mina:tcp:<span class="code-comment">//localhost:8080?sync=<span
class="code-keyword">true</span>&amp;textline=<span class="code-keyword">true</span>"</span>).process(<span
class="code-keyword">new</span> Processor() {
</span>            <span class="code-keyword">public</span> void process(Exchange
exchange) <span class="code-keyword">throws</span> Exception {
                <span class="code-object">String</span> body = exchange.getIn().getBody(<span
class="code-object">String</span>.class);
                exchange.getOut().setBody(<span class="code-quote">"Bye "</span>
+ body);
                exchange.getOut().setHeader(MinaConsumer.HEADER_CLOSE_SESSION_WHEN_COMPLETE,
<span class="code-keyword">true</span>);
            }
        });
</pre>
</div></div>

<h3><a name="MINA-GettheIoSessionformessage"></a>Get the IoSession for message</h3>
<p><b>Available since Camel 2.1</b><br/>
You can get the IoSession from the message header with this key MinaEndpoint.HEADER_MINA_IOSESSION,
and also get the local host address with the key MinaEndpoint.HEADER_LOCAL_ADDRESS and remote
host address with the key MinaEndpoint.HEADER_REMOTE_ADDRESS.</p>

<h3><a name="MINA-ConfiguringMinafilters"></a>Configuring Mina filters</h3>
<p><b>Available since Camel 2.0</b></p>

<p>Filters permit you to use some Mina Filters, such as <tt>SslFilter</tt>.
You can also implement some customized filters. Please note that <tt>codec</tt>
and <tt>logger</tt> are also implemented as Mina filters of type, <tt>IoFilter</tt>.
Any filters you may define are appended to the end of the filter chain; that is, after <tt>codec</tt>
and <tt>logger</tt>.</p>

<p>For instance, the example below will send a keep-alive message after 10 seconds of
inactivity:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">public</span> class KeepAliveFilter <span class="code-keyword">extends</span>
IoFilterAdapter {
    @Override
    <span class="code-keyword">public</span> void sessionCreated(NextFilter nextFilter,
IoSession session)
            <span class="code-keyword">throws</span> Exception {
        session.setIdleTime(IdleStatus.BOTH_IDLE, 10);

        nextFilter.sessionCreated(session);
    }

    @Override
    <span class="code-keyword">public</span> void sessionIdle(NextFilter nextFilter,
IoSession session,
            IdleStatus status) <span class="code-keyword">throws</span> Exception
{
        session.write(<span class="code-quote">"NOOP"</span>); <span class="code-comment">//
NOOP is a FTP command <span class="code-keyword">for</span> keep alive
</span>        nextFilter.sessionIdle(session, status);
    }
}
</pre>
</div></div>

<p>As Camel Mina may use a request-reply scheme, the endpoint as a client would like
to drop some message, such as greeting when the connection is established. For example, when
you connect to an FTP server, you will get a <tt>220</tt> message with a greeting
(<tt>220 Welcome to Pure-FTPd</tt>). If you don't drop the message, your request-reply
scheme will be broken.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
<span class="code-keyword">public</span> class DropGreetingFilter <span class="code-keyword">extends</span>
IoFilterAdapter {
 
    @Override
    <span class="code-keyword">public</span> void messageReceived(NextFilter nextFilter,
IoSession session,
            <span class="code-object">Object</span> message) <span class="code-keyword">throws</span>
Exception {
        <span class="code-keyword">if</span> (message <span class="code-keyword">instanceof</span>
<span class="code-object">String</span>) {
            <span class="code-object">String</span> ftpMessage = (<span class="code-object">String</span>)
message;
            <span class="code-comment">// <span class="code-quote">"220"</span>
is given as greeting. <span class="code-quote">"200 Zzz"</span> is given as a
response to <span class="code-quote">"NOOP"</span> (keep alive)
</span>            <span class="code-keyword">if</span> (ftpMessage.startsWith(<span
class="code-quote">"220"</span>) || or ftpMessage.startsWith(<span class="code-quote">"200
Zzz"</span>)) {
                <span class="code-comment">// Dropping greeting
</span>                <span class="code-keyword">return</span>;
            }
        }
        nextFilter.messageReceived(session, message);
    }
}
</pre>
</div></div>

<p>Then, you can configure your endpoint using Spring DSL:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;bean id=<span class="code-quote">"myMinaFactory"</span>
class=<span class="code-quote">"org.apache.camel.component.mina.MinaComponent"</span>&gt;</span>
    <span class="code-tag">&lt;constructor-arg index=<span class="code-quote">"0"</span>
ref=<span class="code-quote">"camelContext"</span> /&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>
    
&lt;bean id=<span class="code-quote">"myMinaEndpoint"</span>
      factory-bean=<span class="code-quote">"myMinaFactory"</span>
      factory-method=<span class="code-quote">"createEndpoint"</span>&gt;
    <span class="code-tag">&lt;constructor-arg index=<span class="code-quote">"0"</span>
ref=<span class="code-quote">"myMinaConfig"</span>/&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>

<span class="code-tag">&lt;bean id=<span class="code-quote">"myMinaConfig"</span>
class=<span class="code-quote">"org.apache.camel.component.mina.MinaConfiguration"</span>&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"protocol"</span>
value=<span class="code-quote">"tcp"</span> /&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"host"</span>
value=<span class="code-quote">"localhost"</span> /&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"port"</span>
value=<span class="code-quote">"2121"</span> /&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"sync"</span>
value=<span class="code-quote">"true"</span> /&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"minaLogger"</span>
value=<span class="code-quote">"true"</span> /&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"filters"</span>
ref=<span class="code-quote">"listFilters"</span>/&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>

<span class="code-tag">&lt;bean id=<span class="code-quote">"listFilters"</span>
class=<span class="code-quote">"java.util.ArrayList"</span> &gt;</span>
    <span class="code-tag">&lt;constructor-arg&gt;</span>
        <span class="code-tag">&lt;list value-type=<span class="code-quote">"org.apache.mina.common.IoFilter"</span>&gt;</span>
            <span class="code-tag">&lt;bean class=<span class="code-quote">"com.example.KeepAliveFilter"</span>/&gt;</span>
            <span class="code-tag">&lt;bean class=<span class="code-quote">"com.example.DropGreetingFilter"</span>/&gt;</span>
        <span class="code-tag">&lt;/list&gt;</span>
    <span class="code-tag">&lt;/constructor-arg&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>
</pre>
</div></div>

<h3><a name="MINA-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>

     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAMEL/MINA">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=52097&revisedVersion=45&originalVersion=44">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAMEL/MINA?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message