Search code examples
jbpm

How to make JBPM 6.x remote api respond only when the process execution is completed?


In the current implementation of JBPM's remote client API, If I start a process, JBPM sends response immediately after process is started with the process instance id & process status which is effectively in active state, But I am trying to make the Remote API Client wait till the process execution is over & in the response it should state that the process is completed. Is it possible any way without using thread sleep methods?


Solution

  • AFAIK the remote call to start a new process instance returns as soon as the process reaches a safe point and there is no way to change this behavior.

    However, there are many ways how to get notified when the process execution has finished. In my opinion the most elegant one is to use signal end event in your process definition and configure it to use external signalling. You can then subscribe to KIE.SIGNAL JMS queue and wait for your specific signal which indicates that the end of process execution. It would probably be a good idea to make KIE.SIGNAL a topic instead of a queue so you will not lose other external signals in your processes. Maybe there is a better solution but this is the best one I can think of right now.

    BTW, which remote client API do you mean? The one in KIE Workbench or KIE Server? If you use the former one, I would recommend to switch to KIE Server since it is the recommended way of executing processes. Note that there will be no jBPM runtime in KIE Workbench in the upcoming jBPM 7 (see JBPM-5071) and you will then need to switch to KIE Server anyway.