Create a Route and open it in the design workspace. For more information on how to do it, see How to create a Route .
From the palette, drag and drop a cSetBody, and five cMessagingEndpoint components onto the design workspace. Label the components for better identification of their roles and link them together with the Row > Main connection.
Configuring the incoming sub-route
Double-click the testMina component to open its Basic settings view in the Component tab.
In the URI field, enter the code
"timer:testOneWayMina?delay=1000&period=2000"
to define a timer for starting message exchanges. In this use case, we want each message to be delivered after a 1-second delay at a period of 2 seconds.Double-click the initializeRequest component to open its Basic settings view in the Component tab.
Select Constant from the Language list box and type in
"test message\n"
in the Expression field.Double-click the logRequest component to open its Basic settings view in the Component tab.
In the URI field, enter
"log:jobSocketIn"
where the incoming message exchanges are logged.Double-click the jobSocketIn component and click Advanced settings view in the Component tab.
In this use case, we will use the Camel component camel-mina as the transport. To use this component, click
at the bottom of the Dependencies list to add a row and select
mina
from the drop-down list. For more information about Mina, see the site http://camel.apache.org/mina.html.Alternatively, you can use a cConfig component and add the library of MINA to the Dependencies list of the cConfig component. To do so, click
at the bottom of the Dependencies list to add a row. Select this row and click the [...] button at the end to show the [Select Module] wizard.
Select
camel-mina-alldep-2.9.2.jar
from the inner modules and click OK to add it to the Dependencies list.Click the Basic settings view in the Component tab of the jobSocketIn component. In the URI field, enter
"mina:tcp://localhost:" + 8900 + "?textline=true&sync=false"
to send the message to the Mina endpoint of a TCP service on port 8900 as a text line in the InOnly mode.
Configuring the outcoming sub-route
Double-click the jobSocketOut component to open its Basic settings view in the Component tab.
In the URI field, enter
"mina:tcp://localhost:" + 8901 + "?textline=true&sync=false"
of the outcoming socket port.Double-click the logResponse component to open its Basic settings view in the Component tab.
In the URI field, enter
"log:jobSocketOut"
where the outcoming message exchanges are logged.
Press Ctrl+S to save your Route.