|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
how to get all message from queue? |
« View previous topic :: View next topic » |
Author |
Message
|
Francis |
Posted: Tue Oct 26, 2004 1:17 am Post subject: how to get all message from queue? |
|
|
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 |
|
 |
gunter |
Posted: Tue Oct 26, 2004 5:57 am Post subject: |
|
|
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 |
|
 |
Francis |
Posted: Tue Oct 26, 2004 5:03 pm Post subject: |
|
|
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 |
|
 |
Francis |
Posted: Tue Oct 26, 2004 5:57 pm Post subject: |
|
|
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 |
|
 |
kirani |
Posted: Tue Oct 26, 2004 10:34 pm Post subject: |
|
|
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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|