Start Process Instance and capture the end result of the process

Hi,
I have a BPMN which kicks-off with a start event. I have then used an inclusive gateway to invoke two other sub-processes(BusinessTaskRules). Also, I have used an inclusive gateway to wait get the output from both the subprocesses and then proceed. I was able to see the combined end result at the end event. However, I want to send this information to the client who has actually started this process instances. May I know if there is a way to do the same with one single call. Please let me know how to proceed in this use case.

Hi,
If your client is starting a process instance using the REST API, there is a parameter withVariablesInReturn. This defaults to false, if set to true, then the process instance variables will be returned to the client.

See docs here for reference.

Note - if the process uses async continuations, then this call will return with variables as at the continuation, not after…

regards

Rob

Thanks for your reply.
But, yes, since the inclusive gateway and sub-processes are involved, it is async. And i am looking solution for this usecase in-particular.

Hi,
if your process is asynchronous, then I guess you have two options;

  1. Your client could register a callback with the process. Hence your process calls the client back with results.
  2. Or, your process could publish the result to an agreed end point and your client polls the endpoint until the result is available.

Most async patterns will be variations of these two abstractions…

regards

Rob

Rob,
I am bit new to camunda.
I was also thinking in the lines of option2.
Can you please point me to some implementation of Option1 (registering for a callback with the process)?

Hi,
One easy way is the client supplies the callback URL as a string parameter. Hence this becomes a process variable. Then at the end of the process, have a service task which calls this URL.

You may need to think about authorisation of the callback. One way to do this is the client also supplies a token which could be used as a bearer token to be used in the callback.

Bernd talks to this approach in this blog post

regards

Rob