Home > Software engineering >  Batch script to delete MQ queue
Batch script to delete MQ queue

Time:10-03

I need a sample script which will clear IBM mq que below script use to clear rabbit MQ queue Ex-

if [%1]==[] echo Queue Manager Profile was not specified && goto Usage
if [%2]==[] echo Queue Name was not specified && goto Usage

cd /D C:\Capitalware\MQBT\
mqbt.exe QLIST -p %1 -k %2 -t L -f qdepth.txt -D

CodePudding user response:

Your question is about scripting MQ Batch Toolkit (MQBT) for deleting messages from a queue. Note You could have sent a message to Capitalware Support ([email protected]) for help.

The QList function of MQBT is for generating a list of queues of the queue manager.

Also, you appear to be posting only part of the script. Here is the entire sample Windows batch file called ClearQ.bat:

@echo off
setlocal

if [%1]==[] echo Queue Manager Profile was not specified && goto Usage
if [%2]==[] echo Queue Name was not specified && goto Usage

cd /D C:\Capitalware\MQBT\
mqbt.exe QLIST -p %1 -k %2 -t L -f qdepth.txt -D
FOR /F "tokens=1,2" %%A in (qdepth.txt) DO (

   if %%B GTR 0 (
      mqbt.exe ClearQ -p %1 -q %%A
   )
)
del qdepth.txt
goto :DONE

:Usage
echo Usage: %0 QMgr_Profile_Name Queue_Name
goto :DONE

:DONE
endlocal

So, to run it and clear the contains of a single queue called TEST.Q1 of queue manager 'MQA1', you would do:

ClearQ.bat MQA1 TEST.Q1

So, to run it and clear the contains of all queues named TEST.* of queue manager 'MQA1', you would do:

ClearQ.bat MQA1 "TEST.*"

CodePudding user response:

How about something like this?

if "%1"=="" echo Queue Manager Profile was not specified
if "%2"=="" echo Queue Name was not specified

echo CLEAR QLOCAL(%2) | runmqsc %1
  • Related