Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

Load balancing using Mina example

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

Within this demo every ten seconds, a Report object is created from the Camel load balancer server.
This object is sent by the Camel load balancer to a MINA server where the object is then serialized.
One of the two MINA servers (localhost:9991 and localhost:9992) receives the object and enriches
the message by setting the field reply of the Report object. The reply is sent back by the MINA
server to the client, which then logs the reply on the console.

Description of the routes

Wiki Markup
{snippet:id=e1|lang=xml|title=Load balancer|url=camel/trunk/examples/camel-example-loadbalancing/src/main/resources/META-INF/spring/camel-context-loadbalancer.xml}
Wiki Markup
{snippet:id=e1|lang=xml|title=Mina Server 1|url=camel/trunk/examples/camel-example-loadbalancing/src/main/resources/META-INF/spring/camel-context-mina1.xml}
Wiki Markup
{snippet:id=e1|lang=xml|title=Mina Server 2|url=camel/trunk/examples/camel-example-loadbalancing/src/main/resources/META-INF/spring/camel-context-mina2.xml}

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:

Code Block
mvn clean install 

To run the example, then execute the following command in the respective folder:

Code Block
>mina1
mvn exec:java -Pmina1
Code Block
>mina2
mvn exec:java -Pmina2 
Code Block
>loadbalancing
mvn exec:java -Ploadbalancer

and check the result in the console of load balancer.