External Service task for async calling

Can I use external service task for calling async service ? Example - Say I hv a MQ where I need to post a msg and as well get response from the MQ . For this whole process interaction with main workflow can I use external service task ? Is this advisable ? What is the suggestion ?

take a look here for a example of using AMQP with camunda: https://github.com/berndruecker/camunda-spring-boot-amqp-microservice-cloud-example

Yeh …I have seen that but there is no external service task .I know we can communicate with MQ or jms using the pattern shown in the example .But is it possible to have async microservicr call using external service task? Or you do not recommend to use external service task for calling async microservice ?

Hi @anisk,

yes, it’s possible to call async services from the external task. With the external task clients, https://docs.camunda.org/manual/7.11/user-guide/ext-client/ you can invoke your service easily. To complete the service call, you have to translate the response received in your infrastructure into the complete REST call: https://docs.camunda.org/manual/7.11/reference/rest/external-task/post-complete/ (or failure or bpmnError request).

You need the ID of the external task to complete it. The best way to get it is to put it into your service call and the response.

Hope this helps, Ingo

@Ingo_Richtsmeier Thanks for your reply . What is the better way to model it ? Should this async task be fulfilled using external task or it should be modeled as a “request messsage Task”
to send the async request and then “Receive message Task” while getting and processing the response ?
I can understand that both the way would work but will look you suggestion for the best possible option.

Hi @anisk,

there is not right or wrong with the model. From the technical point of view, modeling the send-receive-pattern is closer to the technical, asynchonous truth.

But the readers of your process model could ask: “Why do you use two activities for modeling a single service call, that most times just takes ten seconds to complete?” Here you can go with the external service task to focus on the business view.

Hope this helps, Ingo

Hi @Ingo_Richtsmeier As I understand , In case of external task we need to fetch and lock the task for some time . But in case of my async response , It might take 2-3 days time for receiving the response. Is there anyway NOT to set any value of “lockDuration” to support this typical kind of Async behaviour?

Hi @anisk,

unfortunately not. But you can set the lockDuration to 259.200.000, which is three days in milliseconds.

If you keep the lockDuration empty, you have to handle each died worker by yourself, removing the lock manually, as no machine can decide if it should try it for another time.

Hope this helps, Ingo

I would like to dig up that thread. That pattern does not consider that a response from a messaging service will be so fast that when we get into a rabbit listener with a response the message cannot be correlated because there is no process waiting for a message. I was looking for some solutions but everything eventually runs into the same issue - that asynchronous task can be finished before camunda engine. Is there any way to design a process in this way that we don’t have to worry about a race condition?