When using a queue attached to a Resource Manager, there are cases where a manual operation on the system can lead to deadlock.
Example: element E1 is in the queue, and the corresponding Resource Manager (following step in the workflow) is waiting for the element to get to the top of the queue. An operator opens Orchestrator GUI and destroy the work order.
Result: element E1 will eventually get to the top of the queue, but there is no work order active that will remove it from the queue. All resources are free but since E1 is on top of the queue, no other element will get processed.
Solution: element E1 has to be deleted from the queue when destroying the work order.
With the following workflow it is possible to detect the situation and act on it.
When executed, a work order will run every 5 minutes and detect if there are orphans element in the queue.
An orphan element is one for which the work order that added the element to the queue is either in final state (complete, error, fail) or does not exist.
The configuration is very simple
The queue_id is the name of the queue (not the displayed name); AUTOMATIC_DESTROY is a way to automatically remove those entries from the queue.
NOTE: removing elements from the queue might result in data losses, it is strongly recommended to first execute the workflow with AUTOMATIC_DESTROY set to false and only after verification change it to true.
Attached an export of the workflow