How can i check a camunda process is completed or not in Java

Hi Team

I have requirement to respond to the customer after all Camunda processes completed.
Can you guide me how to check is process completed or not.

I am reading data from Rest service who calls from outside of my application and using that data i will start camunda BPM process manually. But after starting rest response is going to customer without process completion. To avoid this right now i am using thread.sleep(5000) but need to change that.

All my code is in Java.

If you need the process to run to completion before returning a result, you should ensure the process has no wait states, such as user tasks or asynchronous markers. In that case, the call to RuntimeService.startProcessInstanceByXXX() will complete the process before returning.

If there are a lot of steps in the process, in particular ones that call out to external services/systems, Iā€™d re-consider so the call is not hung up waiting for a long time. You could make some steps asynchronous (which is generally good practice anyway if you can) and provide feedback of completion a different way, if possible.

1 Like

Hi Tiesebarrell

My business requirement is to call 5 external services then gather all info then decide it is fraud or not.
So there is no other way for me to hold the customer, it has to be done real time.
Fraud checking the customer is my business case.

In the end event you may add an execution listener which notifies you when the process completes

Thanks for the info Mohit.

I am new to Camunda can u give me some sample code how to do that.

Really appreciate your help.

You can use the execution listeners. Whenever a end event is started a delegate can be called that notifies of process completion.

Hi @korvisuresh and @Mohit_Bhola,

you could also use a message end event and attach the code directly to the implementation:

This will be supported in Camunda 8, too. Listeners are not supported there. Message events | Camunda Platform 8 Docs

Hope this helps, Ingo