Re: How can I dynamically add or modify endpoints in a route?
The RouteBuilder is just java code, so I suggest to add getter/setter to a MyCronRouteBuilder class which extends RouteBuilder. Then you can create a new instance of that, and then use the setter to set your options. And in the configure method you can use the getter to get your options, which you can use in the DSL to set the options you want. On Fri, May 17, 2013 at 6:53 PM, Chris Wolf cwolf.a...@gmail.com wrote: I need to schedule multiple cron jobs in a route. The number and schedules are not known at compile-time, so I need to programatically configure the route at run-time. An abbreviated version of my non-working attempt is shown below. I created an anonymous RouteBuilder, in which I created a route. After, calling context.addRoutes(...), but before starting the context, I want to programmatically tweak the route definition, as shown by the reconfigure(...) function, unfortunately any attempt to lookup the route I just created fails - no routes found. Why? I suspect that the route may actually need to be started for it's initialization to complete, so should I start it, then stop or suspend, then programmatically modify? BTW, I already checked my copy of Camel In Action and http://camel.apache.org/faq.html but no answers for me there context.addRoutes(new RouteBuilder() { public void configure() { from(quartz://demo-1/{{custId}}?cron=* * * * * ? 2036).routeId(sched) .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { // Do something at cron trigger time } }).id(sched.pipline) .to(log:demo-1?showAll=truemultiline=truelevel=INFO); } }); reconfigure(sched.pipline, context); void reconfigure(String downstreamNodeId, CamelContext context) { for (Route route : context.getRoutes()) { // getRoutes() returns zero-length list - why String id = route.getId(); // null - why??? ListService svcs = route.getServices(); Consumer c = route.getConsumer(); } Route sched = context.getRoute(sched); // null -- Claus Ibsen - www.camelone.org: The open source integration conference. Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
Re: How can I dynamically add or modify endpoints in a route?
Actually, after further experimenting, my reconfgure worked, but only after the CamelContext was started. So the implementation was to just have an initial route consuming from a direct:, then, when an message comes in, I dynamically create and add new routes, each headed by a unique instance of quartz://, who's name corresponds to the customer-id, so each customer has their own crontab. Thanks, Chris On Sat, May 18, 2013 at 3:42 AM, Claus Ibsen claus.ib...@gmail.com wrote: The RouteBuilder is just java code, so I suggest to add getter/setter to a MyCronRouteBuilder class which extends RouteBuilder. Then you can create a new instance of that, and then use the setter to set your options. And in the configure method you can use the getter to get your options, which you can use in the DSL to set the options you want. On Fri, May 17, 2013 at 6:53 PM, Chris Wolf cwolf.a...@gmail.com wrote: I need to schedule multiple cron jobs in a route. The number and schedules are not known at compile-time, so I need to programatically configure the route at run-time. An abbreviated version of my non-working attempt is shown below. I created an anonymous RouteBuilder, in which I created a route. After, calling context.addRoutes(...), but before starting the context, I want to programmatically tweak the route definition, as shown by the reconfigure(...) function, unfortunately any attempt to lookup the route I just created fails - no routes found. Why? I suspect that the route may actually need to be started for it's initialization to complete, so should I start it, then stop or suspend, then programmatically modify? BTW, I already checked my copy of Camel In Action and http://camel.apache.org/faq.html but no answers for me there context.addRoutes(new RouteBuilder() { public void configure() { from(quartz://demo-1/{{custId}}?cron=* * * * * ? 2036).routeId(sched) .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { // Do something at cron trigger time } }).id(sched.pipline) .to(log:demo-1?showAll=truemultiline=truelevel=INFO); } }); reconfigure(sched.pipline, context); void reconfigure(String downstreamNodeId, CamelContext context) { for (Route route : context.getRoutes()) { // getRoutes() returns zero-length list - why String id = route.getId(); // null - why??? ListService svcs = route.getServices(); Consumer c = route.getConsumer(); } Route sched = context.getRoute(sched); // null -- Claus Ibsen - www.camelone.org: The open source integration conference. Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen
How can I dynamically add or modify endpoints in a route?
I need to schedule multiple cron jobs in a route. The number and schedules are not known at compile-time, so I need to programatically configure the route at run-time. An abbreviated version of my non-working attempt is shown below. I created an anonymous RouteBuilder, in which I created a route. After, calling context.addRoutes(...), but before starting the context, I want to programmatically tweak the route definition, as shown by the reconfigure(...) function, unfortunately any attempt to lookup the route I just created fails - no routes found. Why? I suspect that the route may actually need to be started for it's initialization to complete, so should I start it, then stop or suspend, then programmatically modify? BTW, I already checked my copy of Camel In Action and http://camel.apache.org/faq.html but no answers for me there context.addRoutes(new RouteBuilder() { public void configure() { from(quartz://demo-1/{{custId}}?cron=* * * * * ? 2036).routeId(sched) .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { // Do something at cron trigger time } }).id(sched.pipline) .to(log:demo-1?showAll=truemultiline=truelevel=INFO); } }); reconfigure(sched.pipline, context); void reconfigure(String downstreamNodeId, CamelContext context) { for (Route route : context.getRoutes()) { // getRoutes() returns zero-length list - why String id = route.getId(); // null - why??? ListService svcs = route.getServices(); Consumer c = route.getConsumer(); } Route sched = context.getRoute(sched); // null
Re: How can I dynamically add or modify endpoints in a route?
Did you try it using Dynamic router http://camel.apache.org/dynamic-router.html ? -- View this message in context: http://camel.465427.n5.nabble.com/How-can-I-dynamically-add-or-modify-endpoints-in-a-route-tp5732775p5732777.html Sent from the Camel - Users mailing list archive at Nabble.com.