To start I just want to let you know I am new to Camel and very recently I grasped its main concepts.
I am trying to create a basic working example using Apache-Came
After much effort, I have found a way to implement this basing myself on the loadbalancer example provided by apache.
I have uploadded the eclipse project to my github account, you can check it working here:
Although my example does respect the overall intended architecture, it does have few differences as explained bellow:
Furthermore, it is also not clear when, where or why MyApp-C replies to MyApp-A with the changed report. This behavior is not specified in the Spring DSL code and so far no one was able to explain to me why this is even happening.
So two problems remain:
In case you are interested, Here is the README.txt I created, with an accurate description of the problem:
Load balancing with MINA Example
This example shows how you can easily use the Camel-MINA component to design a solution allowing for a fault tolerant solution that redirects requests when a server is down. These servers are simple TCP/IP servers created by the Apache MINA framework and run in separate JVMs.
In this example, the load balancer client will generate a report every 10 seconds and send that report to the MINA server running on localhost:9991. This server then forwards the report to the MINA server running on localhost:9993, which then returns the report to the client so it can print it on the console. Each MINA server will change the body of the message so you can see the routes that the report had to use. If for some reason (lets say you pressed CTRL+C), the MINA server running on localhost:9991 is dead, then the loadbalancer will automatically start using the MINA server running on localhost:9992. Once the this MINA server receives the report, it will send it back to the MINA server running on localhost:9993 like nothing has ever happened. If localhost:9991 gets back up again, then the loadbalancer will start using it again.
The load balancer will always attempt to use localhost:9991 before trying to use localhost:9992 no matter what.
Running 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, then execute the following command in the respective folder:
mina1:
mvn exec:java -Pmina1mina2: mvn exec:java -Pmina2
mina3: mvn exec:java -Pmina3
loadbalancing: mvn exec:java -Ploadbalancer
If you hit any problems please let us know on the Camel Forums
http://camel.apache.org/discussion-forums.html
Pedro Martins !
EDIT
In the previous post I had 2 questions: 1. how to do this in java dsl 2. why are the mina servers sending replies.
I will attack problem 1 eventually, but I just want to state that the solution to problem 2 is here: http://camel.465427.n5.nabble.com/Load-balancing-using-Mina-example-with-Java-DSL-td5742566.html#a5742585
Kudos to Mr. Claus for the answer and suggestions.
EDIT
Both problems are now solved and they are both in the same git repository. I hope my code helps people.