The client is in this route.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="service" class="org.apache.camel.example.service.Generator"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="sendMessage">
<from uri="timer://org.apache.camel.example.loadbalancer?period=10s"/>
<bean ref="service" method="createReport"/>
<to uri="direct:loadbalance"/>
</route>
<!-- use failover load balancer in round robin mode, to automatic failover to next server
in case of failure -->
<route id="loadbalancer">
<from uri="direct:loadbalance"/>
<loadBalance inheritErrorHandler="false">
<failover roundRobin="true"/>
<to uri="mina:tcp://localhost:9991?sync=true"/>
<to uri="mina:tcp://localhost:9992?sync=true"/>
</loadBalance>
<log message="${body}"/>
</route>
</camelContext>
</beans>
Note that there is a time component:
<from uri="timer://org.apache.camel.example.loadbalancer?period=10s"/>
This component calls the method createReport of the service bean which is the class type: org.apache.camel.example.service.Generator
. This is the client.
To add a additional MINA server use the following Spring DSL.
<loadBalance inheritErrorHandler="false">
<failover roundRobin="true"/>
<to uri="mina:tcp://localhost:9991?sync=true"/>
<to uri="mina:tcp://localhost:9992?sync=true"/>
<to uri="mina:tcp://localhost:9993?sync=true"/>
</loadBalance>
Then create a third MINA consumer like this:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="service" class="org.apache.camel.example.service.Reporting"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="mina2">
<from uri="mina:tcp://localhost:9993"/>
<setHeader headerName="minaServer">
<constant>localhost:9993</constant>
</setHeader>
<bean ref="service" method="updateReport"/>
</route>
</camelContext>
</beans>
Note that this would require you to start the MINA3 server additionally as well when running the example. The client and the load balancer routes (2 routes) are in the same camel file.
I would suggest that you learn how to read the Spring DSL as it is really worth the effort. Also if you are not familiar with Spring you do need a primer on it. The dependency injection part is especially important.
One last recommendation would be to buy yourself a copy of Camel In Action. It is really a great way to start working with Camel.
If you need further clarification please ask away.