Cancel an async task and move on the next task

Hello All,

We have a flowable model with an async task containing an external api call. When we receive a success response from the external API, the async task will move on to the next task. However, if there is a network failure while calling the API / 500 error from the API, the async task gets retried many times before ending up being a deadletter job.
Now, the problem is, we need to have a functionality where we can manually (from the java application) close that async task and move on to the next task. Is it possible using any flowable component / rest api call?
My understanding is that, for sync task - we can do it with taskService.complete(taskID). But for async task, it is not possible. Is there any way to do this?

The solution will help us a lot. :slight_smile: Thanks in advance.

Hey @DGuha,

You can use a boundary error event to handle unsuccessful REST API calls like that. I suppose you are using an async HTTP Task. If not, can you perhaps be a bit more specific of how your async task looks like?

Cheers,
Filip

1 Like

Hello @filiphr, Thanks for the quick response. Our async task is a service task where java code handles the external api call (throwing all errors so that the async task will fail and retry). We want all network errors to be retried as usual except one specific error (gateway-timeout-error). When this error happens, we want to task to both retry and also wait for a manual continuation (whichever happens early). My understanding is if we use a boundary error event, the process would be terminated without going to the next task.
We have made a change like this for handling such scenario. Could you please validate if there is any better way of doing it?

Thanks for the explanation @DGuha.

What you can do is to throw a BpmnError with the code gateway-timeout-error when your specific error happens. This would make it possible for you to use a boundary error.

It all depends on what you do after your boundary error. e.g. you can do something like:

image

Alternatively, you can also just catch that gateway timeout and do not throw an exception for it. This way the execution will just continue through the regular path. It all depends on what you want to do business wise.

Cheers,
Filip

Thanks again. I genuinely appreciate the help.
I have implemented it as you specified.
Is it possible to stop the timer job execution when manual continuation message is received and the process continues to the next task?
image

Please check this realtime diagram where the process is moved on to the next task, but the timer job is still pending.

I believe what you are looking for is Event based gateway.

image

Using this it will cancel either the timer or the message (depending on which one gets triggered).

Cheers,
Filip

You are a lifesaver. :slight_smile:
My final business process:
image