Handle external task worker shutdown

Hi everyone!

I have an external task on my BPMN scheme and its realization by External Task Client Spring Boot Starter | docs.camunda.org with long-pooling, extending lock and retries number = 0 (don’t want to repeate execution / therefore throw incident f the lock time will expire).

How can i automate incident handling in this case and continue execution on another flow?

Thanks in advance!

Hi @mikheev17 ,

I’m not sure if you really want an incident to be created. When I understood correctly it is rather flow A on sucess and flow B on timeout. Did you consider introducing a new variable to represent this state? Then you could simply add a gateway after your external task to control flow.
From my point of view this also seems cleaner than reacting to an incident inside an incident handler and then move tokens around.

I hope it helps!
Adagatiya

@Adagatiya thank you for your answer! But I didn’t understand the solution. May I ask for details?

You are right - I wouldn’t like an incident to be created. But that’s standard behaviour, isn’t it?
The main concept is to avoid re-execution of the external task after the lock expires (lock_exp_time_) and direct it to flow B. How the introducing of a new variable can solve this problem and make external task completed?

Best regards,
Maksim

Hi @mikheev17 ,

from your first post I assumed that you have an ExternalTaskHandler implementation that processes some logic. I would expect that you can catch an exception or determine a timeout errror. Then you could set variables in your process accordingly, e.g. using ExternalTaskService#complete(String externalTaskId, String workerId, Map<String, Object> variables).

Edit: There is also functionally to extend lock duration. I don’t know the semantic behind timeouts in your case but in case a calculation simply takes too long, this might also a viable option instead of running into an exception.

Kind regards
Adagatiya

Yes, I have an ExternalTaskHandler implemented by a separate microservice which extends lock from time to time.
But what if it goes down while processing? (for example, OutOfMemory…). Is there a handler on camunda server side which can catch timeout error?