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 » how to get all message from queue?

Post new topic  Reply to topic
 how to get all message from queue? « View previous topic :: View next topic » 
Author Message
Francis
PostPosted: Tue Oct 26, 2004 1:17 am    Post subject: how to get all message from queue? Reply with quote

Novice

Joined: 20 Oct 2004
Posts: 10

now ,
in my queue ,there are ten message,
but after i get one message from queue,
the program will throw reasoncode=2033 exception ?
how do i get all message ??

my program is :

MQQueueManager qMgr =new MQQueueManager(qManager);
System.out.println("success connect QueueManager");
int openOptions = MQC.MQOO_INPUT_SHARED | MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_BROWSE;
openOptions=openOptions+MQC.MQOO_BROWSE;


MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options=gmo.options+MQC.MQGMO_SYNCPOINT;
gmo.options=gmo.options+MQC.MQGMO_WAIT;


gmo.waitInterval=3000;
MQMessage inMsg=new MQMessage();


while (true){


mqQueue = qMgr.accessQueue(qName,openOptions);
mqQueue.get(inMsg, gmo);


inMsg.clearMessage();

qMgr.commit();
}
catch (MQException ex) {
System.out.println("Error Code2 : " + ex.reasonCode);
ex.printStackTrace();
}
catch(Exception ex){
System.out.println("Error Code1 : " + ex.toString());
ex.printStackTrace();
}
Back to top
View user's profile Send private message
gunter
PostPosted: Tue Oct 26, 2004 5:57 am    Post subject: Reply with quote

Partisan

Joined: 21 Jan 2004
Posts: 307
Location: Germany, Frankfurt

Quote:
int openOptions = MQC.MQOO_INPUT_SHARED | MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_BROWSE;
openOptions=openOptions+MQC.MQOO_BROWSE;

This is dangerous. The fist statement sets MQC.MQOO_BROWSE, the second removes it and sets another bit? Don't use + and -, use | and & on bit-operations.

Before mqQueue.get(inMsg, gmo); you shoulld set correlationId to MQC.MQCI_NONE and messageId to MQC.MQMI_NONE because every successful get will set this and if you leave this in the object, the next get fails with 2033.
_________________
Gunter Jeschawitz
IBM Certified System Administrator - Websphere MQ, 5.3
Back to top
View user's profile Send private message
Francis
PostPosted: Tue Oct 26, 2004 5:03 pm    Post subject: Reply with quote

Novice

Joined: 20 Oct 2004
Posts: 10

thank u for your advice,
according your message,i write
inMsg.correlationId=MQC.MQCI_NONE;
inMsg.messageId=MQC.MQCI_NONE;
then i can get all message from queue,
many thanks for u
Back to top
View user's profile Send private message
Francis
PostPosted: Tue Oct 26, 2004 5:57 pm    Post subject: Reply with quote

Novice

Joined: 20 Oct 2004
Posts: 10

now ,i send message group ,
in a queue have many group
but now
inMsg.correlationId=MQC.MQCI_NONE;
inMsg.messageId=MQC.MQCI_NONE;
it don't work,
i still only get one message group,
after it throw Exception code 2003 ,

how to write it when send message group and make me get all message group?

thanks again
Back to top
View user's profile Send private message
kirani
PostPosted: Tue Oct 26, 2004 10:34 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Take a look at Chapter 10 in Application Programming Guide.
There you will find very detailed info about how to get different types of messages from the queue.
_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » how to get all message from 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.