Written by

Question shima Avakh · Aug 5

How to Abort All Queued Messages via Command Line

I'm working with IRIS for Health. I need to abort all messages currently in the queue via the command line (IRIS terminal). is there any easy way?

Comments

Ashok Kumar T · Aug 5

Hi @shima Avakh 

Ens.Queueclass provides various methods for working with queues. Queue-related information is stored in the global^Ens.QueueTo abort messages from a specific queue, you can use the following class method

Do ##class(Ens.Queue).AbortQueue(pQueueName) 

Replace pQueueName with the name of the queue you want to abort. This method allows you to target and abort messages in a specific queue.

0
shima Avakh  Aug 5 to Ashok Kumar T

Thanks for the suggestion! Using Do ##class(Ens.Queue).AbortQueue("QueueName") works well for individual queues.

However, I'm looking for a way to abort all messages across all queues without having to specify each pQueueName one by one. 

0
Jeffrey Drumm  Aug 5 to shima Avakh

Here's a short method you can place in a utility class that does what you want:

ClassMethod AbortAll() As%Status
{
    Set tSC = $$$OKSet tQry = ##class(%SQL.Statement).%New()
    Set tSC = tQry.%PrepareClassQuery("Ens.Queue","Enumerate")
    If$$$ISOK(tSC)
    {
        Set tRS = tQry.%Execute()
        While tRS.%Next()
        {
            Set tQueue = tRS.%Get("Name")
            Write !, "Aborting Queue "_tQueue
            Do##class(Ens.Queue).AbortQueue(tQueue)
        }
    }
    Return tSC
}
0
Jeffrey Drumm  Aug 5 to shima Avakh

Also, one might be tempted to simply kill the ^Ens.Queue global.

Don't.

^Ens.Queue is used for other housekeeping tasks, and while killing it will absolutely remove all messages from visibility in the queue viewer, it won't change the message headers for those items from queued status to something else (like aborted or discarded). And it will very likely break other things that you really don't want to break.

0