LoadBalancing Mina ExamplePage edited by Claus IbsenChanges (14)
Full ContentLoad balancing using Mina exampleThis example show how you can easily use the camel-mina component to design a solution The demo starts when every 5th seconds, a Report object is created from the camel load balancer server. Description of the routesLoad balancer <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> <route id="loadbalancer"> <from uri="direct:loadbalance"/> <loadBalance> <roundRobin/> <to uri="mina:tcp://localhost:9991?sync=true&allowDefaultCodec=true"/> <to uri="mina:tcp://localhost:9992?sync=true&allowDefaultCodec=true"/> </loadBalance> <log message="${body}"/> </route> </camelContext> </beans> Mina Server 1 <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 headerName="minaServer"> <constant>localhost:9991</constant> </setHeader> <bean ref="service" method="updateReport"/> </route> </camelContext> </beans> Mina Server 2 <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 headerName="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, execute now 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
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache Camel > LoadBalancing Mina Example confluence