Wait for Task Execution by API call

Hello,

I am new to Camunda and want to use it on side, just to monitor my current process. So i created a bpmn which models my process.
Now I use spring boot and have a controller where the process should start. So if I receive an API call to the endpoint /start I am starting a new process instance. Now I want to continue my normal code execution and update the camunda process if any task is done in the code.
For example I start the process, then the code calls the next function “send Mail”, which is also a camunda task. So after I sent the Mail in my code I want to update the process state and tell that the task “sendMail” is now done successfully.

I dont know which type of tasks I have to create in my bpmn to wait until the process is updated by my java code.

Hello @Kuponchik ,

in general, you could use any kind of implementation. For embedded scenarios, Java Class and Delegate Expression are quite nice. In a remote scenario, the external task pattern will make your life easy.

However, I wonder why you would like to use your own code flow and not let it be orchestrated by the process engine?

Jonathan

Hello @jonathan.lukas ,

Thanks! But how can I complete the process from code (without the Java Delegate script)? Using the RuntimeService I can get the current process instance. But i did not found any function to tell "istance.setTaskCompleted(“taskid”). Or maybe call an API and tell “…/{processID}/{taskID}/complete”. Is there something to do this?

About your question: This is the first step of the project - to create a PoC for an existing project. Later we will use the orchestrated scenario.

Thanks

Hello @Kuponchik ,

what you could do is to use Receive Tasks. Then you can correlate messages via runtime API.

This is how customer also migrated from code-driven applications to process-driven applications.

However, I can just recommend to use service task implementations and split up the code as the process engine then controls the progress of the process instance, saves the state and has capabilities to retry failed tasks and continues where you left off before.

I hope this helps

Jonathan

Hi,
Please try to use an external service task where in the client you can have your code of sending an email and then you can respond back to the process. Refer the link below on how to implement the external task client.

Thanks,
Nandan