Posted: Thu Jul 08, 2010 3:02 am Post subject: Getting messages from queue without deleting them
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.
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
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