You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Load balancing using Mina example

This example show how you can easily use the camel-mina component to design a solution
allowing to distribute message workload on several servers.
These servers are simple TCP/IP servers created by the Apache MINA framework and running in
separate JVMs. The load balancer pattern of Camel which is used top of them allows to
send in a Round Robin model mode the messages created from a camel Bean component
respectively to each server running on localhost:9991 and localhost:9992.

The demo starts when every 5th seconds, a Report object is created from the camel load balancer server.
This object is send by the camel load balancer to a MINA server and object is serialized.
One of the two MINA servers (localhost:9991 and localhost:9992) receives the object and enrich the message
by setting the field reply of the Report object. The reply is send back by the MINA server to the client,
which then logs the reply on the console.

Description of the routes

Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException
Error formatting macro: snippet: java.lang.NullPointerException

How to run the example

To 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

  • No labels