[ 
https://issues.apache.org/jira/browse/CAMEL-19127?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

geyipeng updated CAMEL-19127:
-----------------------------
    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}");
            }
        }));
    }
}

  was:
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:

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


> Cannot add route when route is set to not start automatically
> -------------------------------------------------------------
>
>                 Key: CAMEL-19127
>                 URL: https://issues.apache.org/jira/browse/CAMEL-19127
>             Project: Camel
>          Issue Type: Bug
>          Components: came-core
>    Affects Versions: 3.20.2
>         Environment: win10+jdk17+camel3.20.2+springboot2.7.8
>            Reporter: geyipeng
>            Priority: Critical
>
> 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}");
>             }
>         }));
>     }
> }



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to