No, that is not possible. The fetch and lock API treats all tasks equally that belong to the same topic. As you have noted, you can assign priorities to tasks to control which tasks are fetched next. In addition, the API does not fetch suspended tasks or tasks with zero retries. However, that is all, so there is no general purpose querying possibility for fetch and lock.
i have the same requirement.
In my scenario, i have to fetch a specific task.
I’ve tried to set the topicName with something like ${mySpecificTopicName}, in order to query the external tasks by it’s dedicated topicName.
As per my understanding, there is no possibility to use an expression in topicName field.
Please someone correct me if I’m wrong.
What do you think about the possibility to set the topicName dynamically instead of get the list of all the external tasks and then fetchAndLock one of them ?
Being able to use expressions for an external task topic would certainly be a good addition. Feel free to create a JIRA feature request. You can also consider submitting a pull request for that to get it done.