I have a service task that needs to make a rest call and wait for a callback.
There are two options available for me:
Split the service task in two.
A service task making the rest call and a receive task to be notified when I receive the callback.
Keep it as a single unit of work.
The rest call is made inside the execute method of the handler, but the complete method is not called.
Since I don’t have the instances of the ExternalTask and ExternalTaskService, I have to save the id to DB and when the callback is received I retrieve the id and use the REST API call “complete” to finish the activity.
I’ve been told that this should be a single unit of work and this split is too low level to be included into the BPMN.
Do you know what would be considered best practice in this case?
Also, if you have a better approach please let me know.
Thank you for the reply.
In my case the Camunda engine runs on a separate service and the communication is done trough external tasks.
So I don’t think I can use the provided scenario.
I’m restricted to using the camunda external task client or REST calls.
Both approaches from the first post work.
I just didn’t know which option would be the better one.
I have a hard time figuring out the granularity in the workflow.
For example in the first approach I have a higher granularity, but it simplifies the the code logic.
In the second approach I have less activities in the flow but I have to add extra logic in the code.
I am in the same situation as you. Have a workflow that in one task sends out an external call with a javadelegate to a kafka queue. The next task in the workflow should start when we recieve a message back from the queue. This could take several days.
The first part will lock the task indefinitely.
Here I make the processing for the request and put the message on the queue.
You can use the java delegate (from the external client library), but you can also fetch and lock your tasks trough your own implementation of the rest calls.
The second part will listen for the response message, process it and then complete the task.
The complete is done trough direct call of the rest API.
we used case 2 in my project , I store the external task in redis, while received call back data , I select mapping external task to compete by rest api
Thank you for your answer, however I have problem with the Send something call.
I have two process definitions which run at difference time in day. The “Send something to API” task is a API in external/third party system. Could you help me how I can trigger message event to “Receive task” which belong to process instance called to the API.
Have you experienced problems like this: the “Send something to API” terminate and a callback is sent for the “receive task”, but this is not initialized (or whatever) and the callback fails — that is, after the ACK the called API (Send something API) is already ready to send a callback for “Receive task”, but Camunda has not reached that point yet.