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

Reply via email to