1

Currently I use PCF command to delete a Queue on QMANAGER with

PCFMessage message = new PCFMessage( CMQCFC.MQCMD_DELETE_Q );
message.addParameter( CMQC.MQCA_Q_NAME, name);
agent.send( message );

Could I force delete if queue is occupied?


I have tried without succes on QL

@Override
protected PCFMessage getRequestRemove(String objetName,
        String qmanagerName,boolean forceQmanager) {
    PCFMessage request = new PCFMessage(CMQCFC.MQCMD_DELETE_Q);
        request.addParameter( CMQCFC.MQIACF_PURGE, CMQCFC.MQPO_YES );     
    
    request.addParameter(CMQC.MQCA_Q_NAME, objetName);
    request.addParameter(CMQC.MQIA_Q_TYPE, CMQC.MQQT_LOCAL);
    return request;
}

Error code is Caused by: com.ibm.mq.pcf.PCFException: MQJE001: Code achèvement '2', Motif '3014'. My PCF library is 7.1.0.4

regards

Morag Hughson
  • 7,255
  • 15
  • 44
pcouas
  • 31
  • 1
  • 5
  • Can you clarify if by occupied do you mean the queue has messages on it or that proceses are attached for PUT or GET? – JoshMc Sep 18 '18 at 02:02
  • If you are talking about queues that have message on them then you do have a option to delete those. – JoshMc Sep 18 '18 at 14:32

2 Answers2

3

There is no FORCE option on a DELETE queue command. If the queue is currently open by an application for input and they are waiting in an MQGET you can kick them out with the following command.

MQSC

ALTER QLOCAL(q-name) GET(DISABLED)

PCF

PCFMessage message = new PCFMessage (CMQCFC.MQCMD_CHANGE_Q);
message.addParameter(CMQC.MQCA_Q_NAME, name);
message.addParameter(CMQC.MQIA_INHIBIT_GET, CMQC.MQQA_GET_INHIBITED);
agent.send(message);

However if the queue is currently open and the application is not currently in either an MQGET or an MQPUT, then you cannot kick them out in this way, your only option then is to find the application in question using DISPLAY CONN, and then issue a STOP CONN to get them to release the queue.

The mostly likely occupation of a queue is the long MQGET-waiter, and so the above example command will help for most cases.

Morag Hughson
  • 7,255
  • 15
  • 44
  • I was just typing up a comment with similar info, so thank you for the more detailed answer. One good search to see what has a object open is `DIS CONN(*) TYPE(ALL) WHERE(OBJNAME EQ NAME.OF.QUEUE)` This will show you all connections that have a handle on the queue, you can then issue `STOP CONN` against those connections and try the delete again, but if you have an app that quickly reopens the queue you will have the same problem. Even if you `PUT(DISABLE)` and `GET(DISABLE)` the queue before stopping the CONNs it does not prevent a app from opening the queue for INQUIRE. – JoshMc Sep 17 '18 at 23:40
0

Morag's answer addresses possible ways to disconnect processes that currently have the queue open, if you also want to remove the queue when messages are on the queue you would need to ask MQ to PURGE the messages:

PCFMessage message = new PCFMessage( CMQCFC.MQCMD_DELETE_Q );
message.addParameter( CMQC.MQCA_Q_NAME, name);
message.addParameter( CMQCFC.MQIACF_PURGE, CMQCFC.MQPO_YES );
agent.send( message );
JoshMc
  • 10,239
  • 2
  • 19
  • 38