Hi

Yeah check this page
http://camel.apache.org/running-camel-standalone.html

And the cookbook example it refers to.

On Tue, Nov 5, 2013 at 11:19 PM, pmp.martins
<pmp.mart...@campus.fct.unl.pt> wrote:
>
> I have code a loadbalancer that generates a report every 10 seconds and
> sends it to a MINA server on localhost:9991 or to a MINA server on
> localhost:9992 should the first one fail. Once the MINA servers receive the
> report, they change it and send it back to the loadbalancer, which then
> print the body of the report.
>
> public class MyApp_A {
>
>     public static void main(String... args) throws Exception {
>         // create CamelContext
>         CamelContext context = new DefaultCamelContext();
>
>         context.addRoutes(
>                 new RouteBuilder(){
>
>                     @Override
>                     public void configure() throws Exception {
>
> from("timer://org.apache.camel.example.loadbalancer?period=10s")
>                         .beanRef("service.Generator", "createReport")
>                         .to("direct:loadbalance");
>
>                         from("direct:loadbalance")
>                             .loadBalance().failover()
>                                 // will send to A first, and if fails then
> send to B afterwards
>                                 .to("mina:tcp://localhost:9991?sync=true")
>                                 .to("mina:tcp://localhost:9992?sync=true")
>                             .log("${body}")
>                         .end();
>                     }
>                 }
>                 );
>
>         context.start();
>     }
> }
>
> However, once I execute the loadbalancer it finishes immediately. I tried
> fixing this problem by adding an infinite loop after the context.start()
> call, however this is a terrible solution because the program will simply
> get stuck on the loop and will stop generating reports and sending them.
>
> How do I fix this? How do I keep my loadbalancer running while being able to
> generate requests and print the reports that it receives?
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/How-to-keep-route-running-on-camel-with-JavaDSL-tp5742677.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to