Questions about waiting for remote engine process instance to complete using the REST client SB starter extension

When working on an API that uses the Camunda Platform 7 REST Client Java Complete Spring Boot Starter lib and connects to a remote Camunda 7 Run engine, I’m stuck trying to figure out if the process has completed or what status it is in after starting the process via processDefinitionApi.startProcessInstanceByKey(). The idea is for the process to run as a blocking action, running start-to-finish to get a result before returning a response from our API, or be able to asynchronously notify a consumer of status after this “start process instance” method call until it reaches an end state, whether that’s a success or failure.

How would one do that using the community extension Camunda Platform 7 REST Client Java Complete Spring Boot Starter and a remote Camunda Run engine?

Or how would an event-driven model work for starting a process, letting the external task workers perform their tasks, and then getting some kind of event as to successful completion or some kind of failure that is then captured and mapped as a response to return from our API?

The API has no blocking call that waits until the process instance has been completed. The API will return a positive response once the first transaction has been completed. Here are some suggestions:

  • If your process consists of a single transaction, it will be executed in the same thread as the start event. Thus calling the
  • Change the end event of your process to a message end-event. Use the implementation of the message end-event to make a call back to your client.
  • Once you’ve started the process instance, use the client to regularly check the state of the process instance. Is it still active? Is there an incident? Or has it completed successfully?

I hope this information helps you to implement a solution.

Hi Stephan,

Thanks for your response! I was curious about the rest of the bulleted item you posted above that appears to have been truncated.

As far as the end event to message event suggestion, is there a way to communicate that end state and variables to an external consumer via our API, or would that consumer have to listen for those messages themselves? I guess I’m just having some difficulty wrapping my head around how we might do this asynchronously such that any consumer could eventually get the final result of the process after starting it via our API.

Thanks again!

Right, the truncated bullet point was

Thus calling the process synchronously.

A message end event is implemented via an external task worker or a java delegate. Hence, you can do anything in the implementation:

  • Call a service
  • Publish an event
  • Notify another process

There is no need for the consumer to actively pull the message.
Read more here:

Thanks again, Stephan. One or two more questions, if you’d be so kind.

By this, do you mean if the process is a single task? For now, the process is just a start event, external task that has a worker, and end state. How would we follow that thread to completion?

Which Camunda REST API client method would be best to use for monitoring the state of the process instance during execution? Does the ended property show if the process has completed, or would we need to check another status? (I’ve read in other places that this property is not reliable, ie. is always false.)

Thanks again for all the help!

Before every external task, there is a natural transaction boundary. The tread “ends” at that point and the call is returned.

You’re right, the “ended” flag is deprecated and always false.
You can use the Get Process Instance endpoint. It only lists running process instances. As soon as the process instance completes, it is moved to the historic process instances.