I noticed that Camunda tasks start to be executed BEFORE a spring boot application has completely started. I can see the corresponding log messages even before my CommanLineRunner beans are triggered.
Is this correct behavior? Can it be customized (e.g. postponed)?
I’m not using Spring Boot but Wildfly with SessionBeans and an EjbProcessApplication.
Within the Camunda config Job Executor is disabled by default:
false
Within the PostDeploy of EjbProcessApplication the Job Executor is started then:
@PostDeploy
public void deployed( final ProcessEngine processEngine )
{
...
ProcessEngineConfigurationImpl processEngineConfigurationImpl = (ProcessEngineConfigurationImpl)processEngine.getProcessEngineConfiguration();
JobExecutor jobExecutor = processEngineConfigurationImpl.getJobExecutor();
jobExecutor.start();
}
Thanks for your answer, Frank!
However, this is not applicable to a Spring Boot application since a Camunda spring boot starter is responsible for all the magic.
I didn’t find out how to change the current behavior, however, I started using camunda.bpm.job-execution.core-pool-size and camunda.bpm.job-execution.max-pool-size properties, so Camunda is not allowed to consume too much resources even if the job executor starts too early.
Camunda job executor obtains too many resources (e.g. db connections from a connection pool)
Spring Framework runs CommandLineRunner beans that may also require the same resources
If CommandLineRunner fails with exception (because the resource cannot be acquired) then Spring framework treats the application as failed, so the whole app fails to start.
I assume that Camunda job executor can start doing its job after “Application started” has been written in the logs.
As the JobExecutor itself is an abstract class, you can add your own implementation. But’s really deep in the heart of the process engine and I can’t assess if you can reach your desired goal with your own class.
Thanks for help, @Ingo_Richtsmeier
However, I think it’s all about Spring Boot configuration which is a bit complicated. As of now, the solution with thread pool properties seems to work for me.