cancel
Showing results for 
Search instead for 
Did you mean: 

Wait for process instance to end

languitar
Champ in-the-making
Champ in-the-making
Hi,

is there any way to programmatically wait for to end hat was just started?

I've seen that something like that should be possible with ExecutionListeners. However, I do not want to modify the process description manually just to install such a listener every time. There were several other postings giving hints how to install things programmatically but I could not exactly figure out how to register such a listener. Any code example would be appreciated.

Kind regards,
Johannes
2 REPLIES 2

languitar
Champ in-the-making
Champ in-the-making
Hm, can't edit the broken question, so it should be: Is there any way to programmatically wait for the end of a process that was just started?

Just adding to this: we are not using the engine inside a web server or framework. It's operated standalone.

frederikherema1
Star Contributor
Star Contributor
There is no way to do this, by default -UNLESS- you process only contains automatic steps and no wait-states (eg. user task, receive-task, intermediate events) nor async-activities.

You can roll your custom solution though, if you want. I suggest using an executionListener (see userguide) that is notified when the process ends (event="end"). In this listener, you can call a specific method on either a statically referenced service/map or an injected service/map.

This service/map should contains Barriers mapped to process-instance ID's. When you start a process instance, register the process-id in the service, the service creates a barrier and lets's the current thread wait for it. From your execution-listener, when the process ends, you can call the service using the delegateExecution's processInstanceId to release the barrier. ALso build in a check for process-instances that end immediately, so the no threads can get stuck on a barrier that will never be called…