I’d like to choose the exact moment when jobExecutor (or the whole engine) is activated when starting my application so it waits until all other services are available. Is there a way to do so? Any of the following or similar?
- processEngine.start()
- processEngine.stop()
- processEngine.jobExecutor.start()
- processEngine.jobExecutor.stop()
Hi @mabertran,
I don’t quite understand if you want to attach a listener to one of those phases or trigger starting of engine from your code?
Cheers,
Askar
Do you use Spring? I just implemented a custom JobExecutor that implements SmartLifecycle to achieve this. Pretty simple and straight forward.
I want the engine not to start until all application services are set up, and this takes a while. The best way to achieve that is to manually tell the engine to start (or at least, the job executor).
In my application (grails) this would be done after Bootstrap.groovy
I use groovy, which uses spring so this might work. Is the code public?
Unfortunately: no … but I think I will either write a short blog or integrate it into the spring boot starter.
Basically:
- extend the SpringJobExecutor with an own class and set it on the configuration. Your implementation must implement SmartLifecycle. This basically allows setting “phases” when to run the code. I just set it to Int.MAX, so it runs last. Make sure you use it as spring-bean, not just “new”.
- in the config, set isJobExecutorActivate to false, so the executor is not started with the engine.
- thats it
Thanks for the reply, I’ll try this one!