Asynchronus communication in external task or in camunda


#1

We have a setup where we have multiple process definitions deployed on the same process engine.
These processes are having many steps of type External task mostly.
Now our requirement is like we want asynchronous communication in External Task.

For Example - External task name validateCredentials can give response after an undefined time for the processInstance. But as the external task requires a lock duration which makes its behavior synchronous.

So I had tried for a bigger lock duration in external Task. But that is failing as service response time is not in my hand.

So I am trying for an additional step ReceiveTask type in my process which will get triggered when an external task service response is ready.
But Receive Task uses a messageName for triggering.
As the multiple process can have same external task and it’s next Receive Task is having different messageName, so it is hard for me to hard code messageName in my code.

Is there any suggestion for this problem?

Is there any best practice for asynchronus communication for external task?
Any example or code snippet will be highly appreciated.

Thanks in Advance.


#2

The best thing to do would be to have the service you used to lock the external extend the lock periodically. Then it’ll stay locked as long as the service is alive.


#3

Extend the lock is hitting my performance a lot as I am dealing with millions of processinstance on a single external task.


#4

In what way is it affecting performance?


#5

Because I have to maintain a scheduler having the duration of a task lock, when this time elapse almost around 80% I have to extend the lock duration everytime.

I am having 1 more use case in which external worker is saying they will update the process instance back when their processing will get complete. They want to continous consume the process instance and update them as and when their business logic gets completed means asynchronously.


#6

So having a scheduler on your external task client is causing performance problems? How many schedulers are run by a single client?

I’m not sure what you mean by this, can your re-phrase it?


#7

For Example - we have an external task (validateItemInInventory) this external task call multiple services(in multiple threads) internally to validate an item in inventory.
So the owner of this external task asked me to do something like send all the processInstance as and when it is getting created.
They will return the reponse one by one or in bulk either via processInstanceId or via some correlation key variables.


#8

single schedule is running. But @Niall our test case is totally different.


#9

They - External Task Client.
Order.bpmn (4.4 KB)
For the reference I am attaching my process.


#10

If you like you can have your external task client lock more than one job per request - then you could work on all locked requests in parallel.