Start process instance after engine startup

We have a technical maintenance process that runs every 15minutes. However, it must also be executed directly on engine start since we can not wait for 15min in that case.

We are using spring and I am trying to use a ProcessEnginePlugin#postEngineBuild hook. But it seems I do not get the lifecycle correctly.

Any ideas how I can achieve the use case?

Or maybe its event possible to schedule a timer start event for “do every 15min but no wait before 1st execution”?

Thanks
Jan

@jangalinski could you use a Message Start Event and create a micro-spring app that generates/correlates a message when the engine starts up / when the micro-app starts? And then have a looped timer that runs every 15 min.

@StephenOTT Thats exactly my problem: how does that “micro” application now when to trigger the initial instance? I meanwhile managed to listen on “PostEngineBuild”, but at that point, the process is not yet deployed.

Can I listen on “JobExecutor started”?

@jangalinski I was suggesting that you literally place the micro-app in the camunda server so when camunda start’s up your app starts up at the same time. When your micro-app starts up you program it to check if the camunda server has started and once started, you execute the message which will be picked up by the BPMN process.

Ah, ok … I have an embedded engine, though, so I cannot react on engine start from outside my app. I am going forward with the jobExecutor start event. Will see … but thanks for helping me out!

Hi Jan,

if you have a spring process application then you can use the @PostDeploy annotation.

@Component("my-application")
@ProcessApplication
public class MyApplication extends SpringServletProcessApplication {

	@Autowired
	private AppStarter starter;

	@PostDeploy
	public void onDeployed() throws Exception {
		starter.start();
	}

	@PreUndeploy
	public void onUndeployed() throws Exception {
		starter.stop();
	}
}

Does this work for you?

Note that we fix a lifecycle issue in 7.6, see CAM-6726.

Best regards,
Philipp

@Philipp_Ossler would have been my first choice, but (at least currently) we are not using a process application, we use springs autodeployment.
I will change this in the future.

We found a workaround (starting process via rest from the outside) that is all we need for now. In the future, I would love to have an “onDeployment” notifier, so I can execute code when resources get deployed.
We will have this requirement with dmn based skill based routing … when the dmn table changes, already assigned tasks should be re-assigned in case the groups changed. But thats a different story.

Hi! I need too start a pocess instance after engine startup for 2 (or more) engine

It works fine using:
startProcess(ProcessEngine processEngine) with @PostDeploy annotation

Until I configured as single engine

Using 2 engine process instance start only for for default, how can I start for each engine?

thanks in advance :wink: