Federico Mariani created CAMEL-27077:
----------------------------------------

             Summary: camel-quartz - a scheduler from the registry that is 
already running (spring-boot-starter-quartz) fails the jobs that fire before 
the CamelContext is fully started
                 Key: CAMEL-27077
                 URL: https://issues.apache.org/jira/browse/CAMEL-27077
             Project: Camel
          Issue Type: Bug
          Components: camel-quartz
            Reporter: Federico Mariani


With a Quartz {{Scheduler}} set on the quartz component or autowired from the 
registry, such as the scheduler of {{spring-boot-starter-quartz}}, the 
component stores the CamelContext in the scheduler context only once the 
CamelContext is fully started. The endpoints add their jobs earlier, when they 
start. Spring starts that scheduler before Camel, so a trigger that fires in 
between fails with {{No CamelContext could be found with name: ...}} 
({{CamelJob}} logs {{Failed to execute CamelJob.}} at ERROR), and the fire is 
lost.

{code:java}
// already started, as the SchedulerFactoryBean of Spring does before Camel 
starts
Scheduler scheduler = new StdSchedulerFactory(props).getScheduler();
scheduler.start();
context.getRegistry().bind("myScheduler", scheduler);

from("quartz://myGroup/myTimer?trigger.repeatCount=0&triggerStartDelay=-1000")
    .to("mock:result"); // the fire fails: 0 messages
{code}

The options {{properties}}, {{propertiesRef}} and {{propertiesFile}} are not 
used with such a scheduler, and nothing says so.

Expected: the component stores the CamelContext in such a scheduler when it 
starts, before the endpoints add their jobs. It logs a WARN when the scheduler 
is already running at that point, as a trigger that fires before its route has 
started is still lost (with Spring Boot, {{spring.quartz.auto-startup=false}} 
lets Camel start the scheduler once the routes have started), and when one of 
the properties options is set with it.

_Claude Code on behalf of Federico Mariani_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to