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 » Question about processing messages on a queue

Post new topic  Reply to topic
 Question about processing messages on a queue « View previous topic :: View next topic » 
Author Message
nzr1949
PostPosted: Tue Nov 16, 2004 9:52 am    Post subject: Question about processing messages on a queue Reply with quote

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
View user's profile Send private message
jefflowrey
PostPosted: Tue Nov 16, 2004 10:05 am    Post subject: Reply with quote

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
View user's profile Send private message
bower5932
PostPosted: Tue Nov 16, 2004 11:03 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

You could also go look at the amqsbcg.java program at:

http://www.developer.ibm.com/tech/sampmq.html

It browses a queue.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
nzr1949
PostPosted: Wed Nov 17, 2004 1:14 am    Post subject: Reply with quote

Novice

Joined: 16 Nov 2004
Posts: 15

Thanks for the responses everyone. The supplied link was very useful indeed.
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 » Question about processing messages on a 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.