Reputation: 1
I have the following Camel route which I am trying to run thru the CamelContext directly with autoStartup set to false @Component
@ConfigurationProperties()
public class S3IntegratorRoute extends RouteBuilder {
@Value("${base.url}")
private String url;
@Value("#{${queryParams}}")
private Map<String, String> query;
@Autowired
@Qualifier("jsonConversionProcessor")
private Processor jsonProcessor;
@Override
public void configure() throws Exception {
String queryParams = Util.buildQueryParams(query);
from("timer:mytimer?repeatCount=1")
// from("timer://manualRestart?repeatCount=1")
.routeId("manualRestart").autoStartup(false)
.setHeader(Exchange.HTTP_QUERY, simple(queryParams))
.to(url).process(jsonProcessor);
}
}
I am trying to run this route in the main application class as shown below-
@SpringBootApplication
//@EnableDiscoveryClient
public class CollibraApiApplication {
public static void main(String[] args) throws Exception {
ApplicationContext ctx = SpringApplication.run(CollibraApiApplication.class, args);
S3IntegratorRoute s3IntegratorRoute = ctx.getBean(S3IntegratorRoute.class);
ExtendedCamelContext camelContext = ctx.getBean(ExtendedCamelContext.class);
camelContext.addRoutes(s3IntegratorRoute);
camelContext.start();
}
}
But when I start this spring boot application I am getting following message in console log and the route is not getting started-
] o.a.c.impl.engine.AbstractCamelContext : Skipping starting of route manualRestart as it's configured with autoStartup=false
2023-03-30 14:41:50.451 [] INFO 25808 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Total 1 routes, of which 0 are started
2023-03-30 14:41:50.453 [] INFO 25808 --- [ main] o.a.c.impl.engine.AbstractCamelContext : Apache Camel 3.3.0 (CamelContext: camel-1) started in 0.030 seconds
Can someone please give an example of how to run this route directly thru CamelContext or is there any other way?
Expecting to run the Camel Route directly instead of autoStartup
Upvotes: 0
Views: 553
Reputation: 55525
When using autoStartup(false)
then Camel does NOT start the route, and so when you start CamelContext
(Camel itself) then 0 routes are started as you can see from the log. This is expected. If you want the route to start then remove autoStartup
or set its value to true
.
See the docs on the website about autoStartup for more details.
Upvotes: 0