...
See the Mina documentation how to write your own codec. To use your custom codec with camel-mina you should register your codec in the Registry such as the Spring XML file. Then use the codec option to set your codec with its bean id. See HL7 for examples that has a custom codec.
Sample with sync=false
In this sample we let Camel expose a service that listen for TCP connections on port 6200. We use the textline codec. In out route we create the mina in the from to create the consumer that listen on port 6200:
...
Wiki Markup |
---|
{snippet:id=e4|lang=java|url=activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConsumerTest.java} |
Sample with Spring DSL
Spring DSL can of course also be used for Mina. In the simple sample below we expose a TCP server on port 5555:
Code Block |
---|
|
<route>
<from uri="mina:tcp://localhost:5555?sync=true&textline=true"/>
<to uri="bean:myTCPOrderHandler"/>
</route>
|
In the route above we expose a TCP server on port 5555 using the textline codec and we let a spring bean with the id myTCPOrderHandler handle the request and return a reply. For instance this can be done as:
Code Block |
---|
|
public String handleOrder(String payload) {
...
return "Order: OK"
}
|
Include Page |
---|
| CAMEL:Endpoint See Also |
---|
| CAMEL:Endpoint See Also |
---|
|