Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-19127

Cannot add route when route is set to not start automatically

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Cannot Reproduce
    • 3.20.2
    • 4.0-M3
    • camel-quartz
    • None
    • win10+jdk17+camel3.20.2+springboot2.7.8

    Description

      When I want to listen for events dynamically adding routes while the camel is running and use ScheduledRoutePolicy to manage the start and stop times of routes, I find that when dynamically created routes are set to noAutoStartup, this will not work. Here is the sample code:

      import org.apache.camel.builder.RouteBuilder;
      import org.apache.camel.routepolicy.quartz.SimpleScheduledRoutePolicy;
      import org.springframework.stereotype.Component;

      import java.util.Date;

      @Component
      public class TestRouteBuilder extends RouteBuilder {
      @Override
      public void configure() {
      from("direct:listenEvent").process(exchange -> getContext().addRoutes(new RouteBuilder() {
      @Override
      public void configure() {
      SimpleScheduledRoutePolicy simpleScheduledRoutePolicy = new SimpleScheduledRoutePolicy();
      simpleScheduledRoutePolicy.setRouteStartDate(new Date(System.currentTimeMillis() + 5000));
      from("direct:" + System.currentTimeMillis()).routePolicy(simpleScheduledRoutePolicy).noAutoStartup().log("${body}");
      }
      }));
      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            ggboy geyipeng
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: