camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "pmp.martins" <>
Subject Basic Apache-Camel LoadBalancer-Failover Example
Date Sat, 02 Nov 2013 19:16:09 GMT
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-Camel with
ActiveMQ as a broker and using jms-component as a client of a loadbalancer
using the failover construct. All this is done using the Java DSL only (if

The example consists of 4 main apps, called MyApp-A, MyApp-B, MyApp-C and
MyApp-D. In a normal scenario MyApp-A reads a file from my computer and then
transforms it into a message. Then it sends that message to MyApp-B and
MyApp-B sends it to MyApp-C. 


However, there is a fail scenario. In this scenario, MyApp-A fails to send
the message to MyApp-B. It then send the message to MyApp-D, which in turn
sends it to MyApp-C.


Bellow is the my code for MyApp-A (PS: Is there a way to naturally embed
code here?)

    public class MyApp-A {
        public static void main(String args[]) throws Exception {
            // create CamelContext
            CamelContext context = new DefaultCamelContext();
            // connect to embedded ActiveMQ JMS broker
            ConnectionFactory connectionFactory = 
                new ActiveMQConnectionFactory("vm://localhost");
            // add our route to the CamelContext
            context.addRoutes(new RouteBuilder() {
                public void configure() {
            // start the route and let it do its work
            // stop the CamelContext

I have considered using the [camel-ftp](
but it would not work because MyApp-C would not know that MyApp-B died and
would not know that it had to fetch from MyApp-D.

Now I have several problems and questions:

1. How do I send a message (in this case, the file) from MyApp-A to MyApp-B
which is a different application? What should I actually put in the
`.to(String)` method of the Java DSL?
2. How do I actually code MyApp-B? How do I make it receive a message from A
(which is a different application, possibly in a different machine) and send
it to MyApp-C (I assume that if I find out how to send from MyApp-A to
MyApp-B, I will know how to send from MyApp-B to MyApp-C)?
3. How will MyApp-A detect that MyApp-B failed?
4. Which camel component should I use? 

If you could provide any feedback on my code and on how to fix the problem I
would be more then grateful.

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message