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 <[email protected]> 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=true&multiline=true&level=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???
>             List<Service> 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: [email protected]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to