Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 740F910D60 for ; Sat, 2 Nov 2013 19:16:37 +0000 (UTC) Received: (qmail 65007 invoked by uid 500); 2 Nov 2013 19:16:37 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 64973 invoked by uid 500); 2 Nov 2013 19:16:37 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 64965 invoked by uid 99); 2 Nov 2013 19:16:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Nov 2013 19:16:36 +0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=SPF_PASS,T_FRT_BELOW2,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Nov 2013 19:16:32 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1Vcgg5-0007XP-LZ for users@camel.apache.org; Sat, 02 Nov 2013 12:16:09 -0700 Date: Sat, 2 Nov 2013 12:16:09 -0700 (PDT) From: "pmp.martins" To: users@camel.apache.org Message-ID: <1383419769560-5742551.post@n5.nabble.com> Subject: Basic Apache-Camel LoadBalancer-Failover Example MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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 possible). 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"); context.addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); // add our route to the CamelContext context.addRoutes(new RouteBuilder() { @Override public void configure() { from("file:data/inbox?noop=true")loadbalancer().failover().to("MyApp-B:incomingOrders").to("MyApp-D:incomingOrders").end(); } }); // start the route and let it do its work context.start(); Thread.sleep(10000); // stop the CamelContext context.stop(); } } I have considered using the [camel-ftp](http://camel.apache.org/ftp.html) 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: http://camel.465427.n5.nabble.com/Basic-Apache-Camel-LoadBalancer-Failover-Example-tp5742551.html Sent from the Camel - Users mailing list archive at Nabble.com.