Custom handler for start events

Hi there,

I’m looking for a way to do the following:

When a process instance is to be started either by a timer start event or by a blank start event the handler (or something similar) should be fired.

The reason behind this:
I want to check, if the process is allowed to have multiple instances. If no, is an instance already running? If yes, do not start it. Otherwise start it, of course.

I don’t know what could be the easiest way to achieve this.

More information:
I’m using Camunda with Spring and a programmatically set up “SpringProcessEngineConfiguration” in a Maven project.
It’s a web application running on a Tomcat server.
Camunda-Version: 7.7.0
If you have more questions, feel free to ask. :slight_smile:

Hi Stefan,

In general, you can use execution listeners for this purpose. Implementing this correctly in application code may not be trivial, though, for example simply querying for process instances and then throwing an exception is subject to race conditions (e.g. think about cases where instances are started in parallel).

See Limit number of concurrently running instances of a process definition for some alternative ideas on this topic. One more thing that comes to mind is a unique constraint in the database on the ACT_RU_EXECUTION table. If you want uniqueness only for some definitions, then having an application-side solution could be preferable, though.

Cheers,
Thorben

1 Like

Hi Thorben,

thank you very much. :slight_smile: