Wait state custom code

Hi everyone,

is it possible to execute custom code whenever Camunda suspends a process instance on a wait state? Maybe some kind of a listener or plugin… I wasn’t able to find anything like that in the documentation.

Thanks in advance!

Every execution offers the possibility to add a Listener on ‘START’ or ‘END’ event.

Maybe you could register such a listener on every execution which is a wait state for example on a UserTask, a Intermediate Catch Event, and so on.

Best regards,

Markus

would it be correct to use the Start execution listener of each “wait state” for this?
Their END listener is called when the process instance wakes up.
So this will be:

  • Receive task
  • External task
  • User task (here we probably need the Create Task Listener, since it is probably performed after the Start Execution Listener)
  • intermidiate message catching event
  • everything with “asynchronous before”

Are there any other “wait states” we need to attach to?

thank you :slight_smile:

P.S.
I was still hoping there would be something more generic for process instance suspension. My processes maintain a connection to an external system which is reused between elements of the process, but which needs to be shutdown when the process goes to sleep.

Yes you can try to use Start execution listener.

Take a look at https://github.com/camunda/camunda-bpm-reactor.

With this project it is easy to create the listener and add it “generic” to every of your process definitions.

Hope this will help.