Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
https://camel.apache.org/staging/
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.
Load balancing using Mina exampleThis example shows how you can easily use the Camel-MINA component to design a solution Within this demo every ten seconds, a Report object is created from the Camel load balancer server. Description of the routesError rendering macro 'code': Invalid value specified for parameter 'java.lang.NullPointerException'<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>Error rendering macro 'code': Invalid value specified for parameter 'java.lang.NullPointerException' <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="mina1"> <from uri="mina:tcp://localhost:9991"/> <setHeader name="minaServer"> <constant>localhost:9991</constant> </setHeader> <bean ref="service" method="updateReport"/> </route> </camelContext> </beans>Error rendering macro 'code': Invalid value specified for parameter 'java.lang.NullPointerException' <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:9992"/> <setHeader name="minaServer"> <constant>localhost:9992</constant> </setHeader> <bean ref="service" method="updateReport"/> </route> </camelContext> </beans> How to run the exampleTo compile and install the project in your maven repo, execute the following command on the root of the project: mvn clean install To run the example, then execute the following command in the respective folder: >mina1 mvn exec:java -Pmina1 >mina2 mvn exec:java -Pmina2 >loadbalancing mvn exec:java -Ploadbalancer and check the result in the console of load balancer. |