ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexGeneral IBM MQ SupportClearing all the local Queues

Post new topicReply to topic
Clearing all the local Queues View previous topic :: View next topic
Author Message
vicks_mq
PostPosted: Fri May 10, 2019 4:16 am Post subject: Clearing all the local Queues Reply with quote

Disciple

Joined: 03 Oct 2017
Posts: 155

Hi All, is there a command to clear all the local queues at one go,

I tried using wildcard, but it didn't work

Code:
Runmqsc
CLEAR QL(london.*)
DIDN'T WORK
Back to top
View user's profile Send private message
bruce2359
PostPosted: Fri May 10, 2019 5:34 am Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 8364
Location: US: west coast, almost. Otherwise, enroute.

DIDNT WORK is not an error produced by any MQ internal code or supplied utility. What error did you receive? What does it mean? What research did you do?
_________________
There are two types of people in this world:
1) Those that can extrapolate from incomplete data
Back to top
View user's profile Send private message
vicks_mq
PostPosted: Fri May 10, 2019 5:41 am Post subject: Reply with quote

Disciple

Joined: 03 Oct 2017
Posts: 155

bruce2359 wrote:
DIDNT WORK is not an error produced by any MQ internal code or supplied utility. What error did you receive? What does it mean? What research did you do?


I got this error - "AMQ8147: WebSphere MQ object London.* not found."


IBM Documentation doesn't mention a way to clear the queues.
https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.0.0/com.ibm.mq.adm.doc/q020780_.htm
Back to top
View user's profile Send private message
abhi_thri
PostPosted: Fri May 10, 2019 7:01 am Post subject: Reply with quote

Master

Joined: 17 Jul 2017
Posts: 263
Location: UK

vicks_mq wrote:

I got this error - "AMQ8147: WebSphere MQ object London.* not found."


Clear ql will only work for one queue at a time using the full queue name,

http://www.mqseries.net/phpBB/viewtopic.php?p=168563&sid=ee6d01da2952ede60f234b966011dffc

Also please note the below,
Quote:
If an application has this queue open, or has a queue open that eventually resolves to this queue, the command fails. The command also fails if this queue is a transmission queue, and any queue that is, or resolves to, a remote queue that references this transmission queue, is open.
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Fri May 10, 2019 2:05 pm Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3115
Location: London, ON Canada

As abhi_thri mentioned, the "CLEAR QL" command only works on a single object at a time. Secondly and equally important, if any application has the queue open for either input or output then the "CLEAR QL" command immediately fails.

<Vendor_Plug>

MQ Batch Toolkit is great tool for doing all kinds of maintenance work on MQ. It has 45 separate functions, one of which is called ClearQ. The ClearQ function first checks if IPPROCS and OPPROCS are zero. If they are then it will issue a PCF CLEARQ command otherwise it will destructively get all messages from the queue. It takes the queue name as a parameter but MQ Batch Toolkit is designed to be used in a script or batch file.

Here's a ClearQ.bat file:

Code:
@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


You would call the batch file as follows:
Code:
CLearQ.bat MQWT1 LONDON.*


Here's what the script does:
(1) First it gets a list of queue names with the current queue depth outputted into a file called qdepth.txt
(2) The FOR loop simply extracts 1 line at a time from the file and breaks the line into 2 tokes: queue name and queue depth
(3) If the queue depth is great than 0 then call MQBT's CLEARQ command
(4) Delete the temporary qdepth.txt file.

</Vendor_Plug>

Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
Andyh
PostPosted: Sat May 11, 2019 1:38 am Post subject: Reply with quote

Disciple

Joined: 29 Jul 2010
Posts: 160

Be very careful about deleting messages from "ALL" local queues.
For example this would be a very dangerous thing to do for almost any SYSTEM.* queue.
Back to top
View user's profile Send private message
PaulClarke
PostPosted: Sat May 11, 2019 1:21 pm Post subject: Reply with quote

Guardian

Joined: 17 Nov 2005
Posts: 936
Location: New Zealand

I agree with Andy that you have to be very careful about clearing system queues. It is rarely a good idea. With that in mind here is the script to clear any queue in MQSCX where we make sure that the queue is not a SYSTEM queue before we clear it.
Code:
func clearq(q)

foreach(DISPLAY Q(<@q>))

  if (! (queue == "SYSTEM.*"))
    @thisq = QUEUE
    print "Clearing queue",@thisq
    CLEAR QLOCAL(<@thisq>)
  endif

endfor

endfunc

clearq("*TEST*")

The script defines a simple function which is then called from the last line. You can see how easy it is to issue an MQ command and process the results in MQSCX. Note that the script allows wildcards anywhere in the name. To do what you want you would just say
Code:
clearq("london.*")


Cheers,
Paul.
_________________
Paul Clarke
MQGem Software
www.mqgem.com
Back to top
View user's profile Send private message Visit poster's website
gbaddeley
PostPosted: Sun May 12, 2019 4:02 pm Post subject: Reply with quote

Padawan

Joined: 25 Mar 2003
Posts: 1949
Location: Melbourne, Australia

Andyh wrote:
Be very careful about deleting messages from "ALL" local queues.
For example this would be a very dangerous thing to do for almost any SYSTEM.* queue.

That's the reason why MQ does not allow CLEAR QLOCAL with a wildcarded queue name. It's too easy to make a blunder.
_________________
Glenn
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexGeneral IBM MQ SupportClearing all the local Queues
Jump to:



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.