Fetch and lock external task by local variable

Can I fetch and lock external tasks filtered by the value of a local variable?

so you;re looking to only lock only tasks that have a specific local variable?
what is the use case for that?

Thanks for answering.

My use case is:

A Camunda Task consume a Third API Rest and wait until a that Task is completed though Camunda Rest API.

I already achieved my goal using a Camunda User Task and a Java Delete Code for a Task Listener on create task event. My problem is when the Third API Rest is down and I need to retry the request.

A possible solution is the following but it is not the best.

public class CustomTaskListener implements TaskListener {

    public void notify(DelegateTask execution) {
    	boolean isAPIError = false;
    	do {
    		try {

    			isAPIError = false;
        		//consume Third API Rest
    		catch(APIException e) {
    			//If there is an error, retry
    			isAPIError = true;

So now I’m exploring Camunda External Task but I need to fetch and lock an specific external task in order to complete it.

you can solve this problem by usingasync-continuation’s retry mechanism