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 > MINA
Date Wed, 07 Aug 2013 06:56: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/MINA">MINA</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (4)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-unchanged" >h2. MINA Component <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*Deprecated*
<br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{warning:title=Deprecated}
<br>This component is deprecated as the Apache Mina 1.x project is EOL. Instead use
[Mina2] or [Netty] instead. <br>{warning} <br> <br></td></tr>
            <tr><td class="diff-unchanged" >The *mina:* component is a transport
for working with [Apache MINA|http://mina.apache.org/] <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>{include:Endpoint See Also}
<br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">-
[Camel Netty|http://camel.apache.org/netty.html] <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">-
[Mina2] <br>- [Netty] <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="MINA-MINAComponent"></a>MINA Component</h2>
<p><b>Deprecated</b></p>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16"
height="16" align="absmiddle" alt="" border="0"></td><td><b>Deprecated</b><br
/>This component is deprecated as the Apache Mina 1.x project is EOL. Instead use <a
href="/confluence/display/CAMEL/MINA2" title="MINA2">MINA2</a> or <a href="/confluence/display/CAMEL/Netty"
title="Netty">Netty</a> instead.</td></tr></table></div>

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

<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-mina&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="MINA-URIformat"></a>URI format</h3>

<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;">
mina:tcp://hostname[:port][?options]
mina:udp://hostname[:port][?options]
mina:vm://hostname[:port][?options]
</pre>
</div></div>
<p>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 if no codec is specified the default uses a basic <tt>ByteBuffer</tt>
based codec.</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"
class="external-link" 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>
<div class="confluenceTableSmall"><div class='table-wrap'>
<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'> 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'> 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>&#35;myCodec</tt> to look up a bean with the <tt>id</tt>
value, <tt>myCodec</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>disconnect</tt> </td>
<td class='confluenceTd'> <tt>false</tt> </td>
<td class='confluenceTd'> <b>Camel 2.3:</b> Whether or not to disconnect(close)
from Mina session right after use. Can be used for both consumer and producer. </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 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'> 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>true</tt> </td>
<td class='confluenceTd'> Setting to set endpoint as one-way or request-response. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>lazySessionCreation</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> Sessions can be lazily created to avoid exceptions, if the
remote server is not up and running when the Camel producer is started. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>timeout</tt> </td>
<td class='confluenceTd'> <tt>3000</tt> </td>
<td class='confluenceTd'> 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'> You can configure the encoding (a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/nio/charset/Charset.html"
class="external-link" 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()"
class="external-link" 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. 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'> 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'> You can set a list of <a href="http://mina.apache.org/iofilter.html"
class="external-link" rel="nofollow">Mina IoFilters</a> to register. The <tt>filters</tt>
value must be one of the following:
<ul>
	<li><b>Camel 2.2:</b> comma-separated list of bean references (e.g. <tt>&#35;filterBean1,#filterBean2</tt>)
where each bean must be of type <tt>org.apache.mina.common.IoFilter</tt>.</li>
	<li><b>before Camel 2.2:</b> a reference to a bean of type <tt>List&lt;org.apache.mina.common.IoFilter&gt;</tt>.</li>
</ul>
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>encoderMaxLineLength</tt> </td>
<td class='confluenceTd'> <tt>&#45;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>decoderMaxLineLength</tt> </td>
<td class='confluenceTd'> <tt>&#45;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'> The TCP producer is 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 has a pooled service which ensured it was already
thread safe and supported concurrency already. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>allowDefaultCodec</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> The mina component installs a default codec if both, <tt>codec</tt>
is <tt>null</tt> and <tt>textline</tt> is <tt>false</tt>.
Setting <tt>allowDefaultCodec</tt> to <tt>false</tt> prevents the
mina component from installing a default codec as the first element in the filter chain. This
is useful in scenarios where another filter must be the first in the filter chain, like the
SSL filter. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>disconnectOnNoReply</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> <b>Camel 2.3:</b> If sync is enabled then this
option dictates MinaConsumer if it should disconnect where there is no reply to send back.
</td>
</tr>
<tr>
<td class='confluenceTd'> <tt>noReplyLogLevel</tt> </td>
<td class='confluenceTd'> <tt>WARN</tt> </td>
<td class='confluenceTd'> <b>Camel 2.3:</b> If sync is enabled this option
dictates MinaConsumer which logging level to use when logging a there is no reply to send
back. Values are: <tt>FATAL, ERROR, INFO, DEBUG, OFF</tt>. </td>
</tr>
</tbody></table>
</div>
</div>

<h3><a name="MINA-Usingacustomcodec"></a>Using a custom codec</h3>

<p>See the <a href="http://mina.apache.org/tutorial-on-protocolcodecfilter.html"
class="external-link" 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">
<script type="syntaxhighlighter" class="theme: Default; brush: java; gutter: false"><![CDATA[
from("mina:tcp://localhost:" + port1 + "?textline=true&amp;sync=false").to("mock:result");
]]></script>
</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">
<script type="syntaxhighlighter" class="theme: Default; brush: java; gutter: false"><![CDATA[
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");

template.sendBody("mina:tcp://localhost:" + port1 + "?textline=true&amp;sync=false", "Hello
World");

assertMockEndpointsSatisfied();
]]></script>
</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">
<script type="syntaxhighlighter" class="theme: Default; brush: java; gutter: false"><![CDATA[
from("mina:tcp://localhost:" + port2 + "?textline=true&amp;sync=true").process(new Processor()
{
    public void process(Exchange exchange) throws Exception {
        String body = exchange.getIn().getBody(String.class);
        exchange.getOut().setBody("Bye " + body);
    }
});
]]></script>
</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">
<script type="syntaxhighlighter" class="theme: Default; brush: java; gutter: false"><![CDATA[
String response = (String)template.requestBody("mina:tcp://localhost:" + port2 + "?textline=true&amp;sync=true",
"World");
assertEquals("Bye World", response);
]]></script>
</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="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
   &lt;route&gt;
     &lt;from uri="mina:tcp://localhost:5555?textline=true"/&gt;
     &lt;to uri="bean:myTCPOrderHandler"/&gt;
  &lt;/route&gt;
</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="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
    public String handleOrder(String payload) {
        ...
        return "Order: OK"
   }
</pre>
</div></div>

<h3><a name="MINA-ConfiguringMinaendpointsusingSpringbeanstyle"></a>Configuring
Mina endpoints using Spring bean style</h3>

<p>Configuration of Mina endpoints is 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">
<script type="syntaxhighlighter" class="theme: Default; brush: xml; gutter: false"><![CDATA[
&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;
&lt;bean id="myMinaFactory" class="org.apache.camel.component.mina.MinaComponent"&gt;
    &lt;!-- we must provide a camel context so we refer to it by its id --&gt;
    &lt;constructor-arg index="0" ref="myCamel"/&gt;
&lt;/bean&gt;

&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="myMinaEndpoint"
      factory-bean="myMinaFactory"
      factory-method="createEndpoint"&gt;
    &lt;!-- and here we can pass it our configuration --&gt;
    &lt;constructor-arg index="0" ref="myMinaConfig"/&gt;
&lt;/bean&gt;

&lt;!-- this is our mina configuration with plain properties --&gt;
&lt;bean id="myMinaConfig" class="org.apache.camel.component.mina.MinaConfiguration"&gt;
    &lt;property name="protocol" value="tcp"/&gt;
    &lt;property name="host" value="localhost"/&gt;
    &lt;property name="port" value="1234"/&gt;
    &lt;property name="sync" value="false"/&gt;
&lt;/bean&gt;
]]></script>
</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">
<script type="syntaxhighlighter" class="theme: Default; brush: xml; gutter: false"><![CDATA[
&lt;route&gt;
    &lt;!-- here we route from or mina endpoint we have defined above --&gt;
    &lt;from ref="myMinaEndpoint"/&gt;
    &lt;to uri="mock:result"/&gt;
&lt;/route&gt;
]]></script>
</div></div>

<h3><a name="MINA-ClosingSessionWhenComplete"></a>Closing Session When Complete</h3>

<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="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
        from("mina:tcp://localhost:8080?sync=true&amp;textline=true").process(new Processor()
{
            public void process(Exchange exchange) throws Exception {
                String body = exchange.getIn().getBody(String.class);
                exchange.getOut().setBody("Bye " + body);
                exchange.getOut().setHeader(MinaConstants.MINA_CLOSE_SESSION_WHEN_COMPLETE,
true);
            }
        });
</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>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>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/check.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>If using the <tt>SslFilter</tt>
you need to add the <tt>mina-filter-ssl</tt> JAR to the classpath.</td></tr></table></div>

<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="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
public class KeepAliveFilter extends IoFilterAdapter {
    @Override
    public void sessionCreated(NextFilter nextFilter, IoSession session)
            throws Exception {
        session.setIdleTime(IdleStatus.BOTH_IDLE, 10);

        nextFilter.sessionCreated(session);
    }

    @Override
    public void sessionIdle(NextFilter nextFilter, IoSession session,
            IdleStatus status) throws Exception {
        session.write("NOOP"); // NOOP is a FTP command for keep alive
        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="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
public class DropGreetingFilter extends IoFilterAdapter {

    @Override
    public void messageReceived(NextFilter nextFilter, IoSession session,
            Object message) throws Exception {
        if (message instanceof String) {
            String ftpMessage = (String) message;
            // "220" is given as greeting. "200 Zzz" is given as a response to "NOOP" (keep
alive)
            if (ftpMessage.startsWith("220") || or ftpMessage.startsWith("200 Zzz")) {
                // Dropping greeting
                return;
            }
        }
        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="theme: Default; brush: xml; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
&lt;bean id="myMinaFactory" class="org.apache.camel.component.mina.MinaComponent"&gt;
    &lt;constructor-arg index="0" ref="camelContext" /&gt;
&lt;/bean&gt;

&lt;bean id="myMinaEndpoint"
      factory-bean="myMinaFactory"
      factory-method="createEndpoint"&gt;
    &lt;constructor-arg index="0" ref="myMinaConfig"/&gt;
&lt;/bean&gt;

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

&lt;bean id="listFilters" class="java.util.ArrayList" &gt;
    &lt;constructor-arg&gt;
        &lt;list value-type="org.apache.mina.common.IoFilter"&gt;
            &lt;bean class="com.example.KeepAliveFilter"/&gt;
            &lt;bean class="com.example.DropGreetingFilter"/&gt;
        &lt;/list&gt;
    &lt;/constructor-arg&gt;
&lt;/bean&gt;
</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>

<ul class="alternate" type="square">
	<li><a href="/confluence/display/CAMEL/MINA2" title="MINA2">MINA2</a></li>
	<li><a href="/confluence/display/CAMEL/Netty" title="Netty">Netty</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/MINA">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=52097&revisedVersion=63&originalVersion=62">View
Changes</a>
                |
        <a href="https://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