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 API Support » Getting messages from queue without deleting them

Post new topic  Reply to topic
 Getting messages from queue without deleting them « View previous topic :: View next topic » 
Author Message
mitoiuv
PostPosted: Thu Jul 08, 2010 3:02 am    Post subject: Getting messages from queue without deleting them Reply with quote

Novice

Joined: 06 Jul 2010
Posts: 20

Hi,

I'm having troubles getting the messages from a queue without removing them... I read a post from a forum that states that it could be done in the following way.

Code:

You need to open the queue with MQOO_BROWSE option. Then on your first read you do a GET using the MQGMO_BROWSE_FIRST option. Finally, your subsequent GET's should use the MQGMO_BROWSE_NEXT option.

Note: MQOO is MQ open options and MQGMO is MQ Get Message Options.


So i did something like this

Code:

/******************************************************************/
  /*                                                                */
  /*   Open the named message queue for input; exclusive or shared  */
  /*   use of the queue is controlled by the queue definition here  */
  /*                                                                */
  /******************************************************************/
  queue.setOpenOptions(
                   MQOO_BROWSE
                 + MQOO_INPUT_AS_Q_DEF /* open queue for input      */
                 + MQOO_FAIL_IF_QUIESCING
                             );        /* but not if MQM stopping   */
  queue.open( );


And this

Code:

/******************************************************************/
  /*                                                                */
  /*   Get messages from the message queue                          */
  /*   Loop until there is a failure                                */
  /*                                                                */
  /******************************************************************/
  msg.useEmptyBuffer( buffer, sizeof( buffer ) - 1 );
                                 /* buffer size available for GET   */
  gmo.setOptions( MQGMO_BROWSE_FIRST | MQGMO_WAIT | MQGMO_BROWSE_NEXT |   /* wait for new messages           */
                  MQGMO_FAIL_IF_QUIESCING );
  gmo.setWaitInterval( 15000 );  /* 15 second limit for waiting     */


But it seems that i'm not doing it right because I can read the messages from the queue but they are deleted after i read them.

If someone could help me on this I would appreciate it very much.

thank you
Back to top
View user's profile Send private message
Mr Butcher
PostPosted: Thu Jul 08, 2010 4:00 am    Post subject: Reply with quote

Padawan

Joined: 23 May 2005
Posts: 1716

to me it looks like you are using forwse first and browse next together on the mqget, and not browse first on the first get and browse next on the subsequend gets.

read what you have quoted in the beginning of your post.....
_________________
Regards, Butcher
Back to top
View user's profile Send private message
mitoiuv
PostPosted: Thu Jul 08, 2010 4:11 am    Post subject: Solved Reply with quote

Novice

Joined: 06 Jul 2010
Posts: 20

Managed to see that the BROWSE option is working
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 API Support » Getting messages from queue without deleting them
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.