|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Question about processing messages on a queue |
« View previous topic :: View next topic » |
Author |
Message
|
nzr1949 |
Posted: Tue Nov 16, 2004 9:52 am Post subject: Question about processing messages on a queue |
|
|
Novice
Joined: 16 Nov 2004 Posts: 15
|
Hi guys,
I am a little stuck at the moment. What I'm trying to do is read each of the messages on a queue one at a time. I want to do it in browse mode so that I don't delete them as they are read. At the moment I have set all my options as follows:
// queue manager options
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT
| MQC.MQOO_INQUIRE | MQC.MQOO_BROWSE;
// get message options
MQGetMessageOptions ops = new MQGetMessageOptions();
ops.options = MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_FIRST; ops.waitInterval = MQC.MQWI_UNLIMITED;
And the code that does the reading:-
//*****************************************************
int count = 0;
while (count < getNoMessages())
{
String filename = "";
this.myQueue.get(msg, ops);
filename = serverNamingConvention + "_" + count;
writeFile(msg, filename);
count++;
}
//*****************************************************
What I have managed to get working is to read the first message on the queue, which I managed by setting the message option MQC.MQGMO_BROWSE_FIRST. When I run the above code, it writes the first message on the queue to every file it creates. So, if there are four messages on the queue, it will create four files which all contain the same message data, which is the first one because that's what I specified. My problem is that I'm not sure how to modify my options so that it reads all the messages and writes each to a file (instead of always the first as it does now). Remember that I wish to do this in browse mode. What options do I need to change for my get message options and my queue manager options (if any)? Will these changes have any bearings on the code in the while() loop above?
Thanks |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Nov 16, 2004 10:05 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Please review the section in the Application Programming Guide on how to browse to the next message. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
bower5932 |
Posted: Tue Nov 16, 2004 11:03 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
|
Back to top |
|
 |
nzr1949 |
Posted: Wed Nov 17, 2004 1:14 am Post subject: |
|
|
Novice
Joined: 16 Nov 2004 Posts: 15
|
Thanks for the responses everyone. The supplied link was very useful indeed. |
|
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
|
|
|
|