Job Executor starts executing tasks BEFORE a spring boot app has startet

Hi!

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)?

Thank you!

Hi Vadim,

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();
    }

Regards, Frank

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.

Hello @vadim.prudnikov ,

please find the spring boot configuration here:

https://docs.camunda.org/manual/7.15/user-guide/spring-boot-integration/configuration/

Maybe you could try to make the job executor deployment-aware.

Jonathan

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.

Hi @vadim.prudnikov,

usually this is not a problem. When the job executor starts, all classes are loaded.

Why do you want to avoid it?

Hope this helps, Ingo

Hi @Ingo_Richtsmeier,

This is because of the following sequence:

  • 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.

Hi @vadim.prudnikov,

the job executor is started here: camunda-bpm-platform/ProcessEngineImpl.java at master · camunda/camunda-bpm-platform · GitHub

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.

Hope this helps, Ingo

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.