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 Index » IBM MQ Java / JMS » Clearing a particular Queue

Post new topic  Reply to topic
 Clearing a particular Queue « View previous topic :: View next topic » 
Author Message
adivyayadav
PostPosted: Mon May 16, 2011 4:10 am    Post subject: Clearing a particular Queue Reply with quote

Novice

Joined: 09 Mar 2011
Posts: 10

I am writing a program to read all the messages from a given Queue.
==============================================
public static void clearQueue(String queueName) throws Exception {
try {
MQMessage mqMessage = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options= MQC.MQGMO_NO_SYNCPOINT; //Set no sync point
gmo.options= MQC.MQGMO_CONVERT; //Handles ASCII/EBCDIC
gmo.options= MQC.MQGMO_WAIT;//Wait until message arrives
gmo.waitInterval= 3000;

MQQueue queueHandle = qMgr.accessQueue("Testing", MQ_Q_OPEN_OPTIONS);
int queueDepth = queueHandle.getCurrentDepth();

if (queueDepth > 0) {
System.out.println("Queue depth = "+ queueDepth);
for (int i = 0; i < queueDepth; i++) {
queueHandle.get(mqMessage,gmo);
System.out.println("\n"+mqMessage.readLine());
gmo.options = MQC.MQGMO_MSG_UNDER_CURSOR;
gmo.options = MQC.MQGMO_BROWSE_NEXT;

}
return;
}
} catch (Exception e) {

}
}








It gets the first message and then gives an error
[color=red][b]MQJE001: Completion Code 2, Reason 2033[/b][/color]


Can any help??
Back to top
View user's profile Send private message
joebuckeye
PostPosted: Mon May 16, 2011 4:51 am    Post subject: Reply with quote

Partisan

Joined: 24 Aug 2007
Posts: 365
Location: Columbus, OH

And did you look up what reason code 2033 means?

When developing MQ apps you need to learn to look up what these reason codes mean.

Once you know what the reason codes mean you can start to figure out how to solve your problem.

If you are on a UNIX like server you should try the command: mqrc <reason code>
Back to top
View user's profile Send private message
zpat
PostPosted: Mon May 16, 2011 5:09 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

Don't loop for the queue depth. Messages may arrive or leave in the meantime.

Simply loop until 2033 is received. This is a NORMAL return code and means the queue is empty.

You won't clear a queue by browsing the messages!

Just open the queue for input, get the messages until 2033 then close the queue.

Forget about browse, cursor, wait - all are irrelevant for simply removing messages.
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Mon May 16, 2011 6:49 am    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

zpat wrote:
Simply loop until 2033 is received. This is a NORMAL return code and means the queue is empty.

More precisely, it means there are no messages available that meet your selection criteria. There might be some available messages on the queue and you can get a 2033 if you are looking for a specific message. There may be no available messages even though the q depth is > 0 because they may be expired messages or uncommitted messages.
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon May 16, 2011 7:08 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

PeterPotkay wrote:
zpat wrote:
Simply loop until 2033 is received. This is a NORMAL return code and means the queue is empty.

More precisely, it means there are no messages available that meet your selection criteria. There might be some available messages on the queue and you can get a 2033 if you are looking for a specific message. There may be no available messages even though the q depth is > 0 because they may be expired messages or uncommitted messages.


In particular, the MQMessage object is altered by the get operation.
Back to top
View user's profile Send private message
zpat
PostPosted: Mon May 16, 2011 7:30 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

All that may be true but a little advanced bearing in mind the apparent basic confusion between reading/browsing and clearing the queue.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Clearing a particular Queue
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.