How to start a process asynchronously via Java API?

HI,

I am using this code to fire a process

 runtimeService
                .startProcessInstanceByKey("hello_world") // have tried execute also

but this is a blocking call, is there a method which is async ?

Sherry

Hello @sherry-ummen ,

the behaviour of the engine is driven by the process itself.
A good practice is adding the „async before“ flag at the start event.
By doing this, the job executor will run your process from start.

Hope this helps

Jonathan

1 Like

Thank you

Ohh alright. Is there a way by default I can may all the process start async? Else it would require every person who is creating a process to remember to make it async at the start.

Hello @sherry-ummen ,

usually it is modelled in the process.

An alternative would be to create a process engine plugin containing a deployment listener, I cannot provide an example right now.

Jonathan

Alright. I found one way in Stackoverflow … haven’t tried it https://stackoverflow.com/a/51167300

Do you see an issue with this approach ?

Hello @sherry-ummen ,

this is exactly what I had in mind. In my opinion, this should work.

Jonathan