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 » Browsing a queue in C#

Post new topic  Reply to topic
 Browsing a queue in C# « View previous topic :: View next topic » 
Author Message
HeadOffice
PostPosted: Wed Apr 23, 2008 12:24 pm    Post subject: Browsing a queue in C# Reply with quote

Newbie

Joined: 13 Mar 2008
Posts: 9

Am I missing something or does the documentation have its own steep learning curve?

I'm trying to browse messages from the queue (leaving them there for other applications) and from what I can tell I just create my GetMessageOptions object and add to the Options property the following value:

Code:
IBM.WMQ.MQC.MQGMO_BROWSE_FIRST

and for subsequent calls
Code:
IBM.WMQ.MQC.MQGMO_BROWSE_NEXT


Then I just call 'Queue.Get()'. However, the call still removes the message from the queue.

How can I peek at these messages? Perhaps my brain is not working correctly.

Thanks in advance...
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Wed Apr 23, 2008 12:31 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You have to use at least
Quote:
public void Get(MQMessage message,
MQGetMessageOptions getMessageOptions)

_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
HeadOffice
PostPosted: Wed Apr 23, 2008 12:42 pm    Post subject: I do... Reply with quote

Newbie

Joined: 13 Mar 2008
Posts: 9

Sorry -- should have been explicit. Yes, calling Get as follows (compiles cleanly - no errors or warnings)...

Code:

// msgGet already exists - so clear it out ready to work
msgGet.ClearMessage();

// create new message options
MQGetMessageOptions opt = new MQGetMessageOptions();
if ( opt != null ) {
    opt.Options = IBM.WMQ.MQC.MQGMO_BROWSE_FIRST;
    this.msgGet.CorrelationId = IBM.WMQ.MQC.MQMI_NONE;
    this.msgGet.MessageId = IBM.WMQ.MQC.MQMI_NONE;

    // now just peek at the first message - queue already exists
    queue.Get( msgGet, opt );
}
Back to top
View user's profile Send private message Send e-mail
PeterPotkay
PostPosted: Wed Apr 23, 2008 5:29 pm    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

What options did you use when opening the queue? Did you specify MQOO_BROWSE? (you need to) Or did you just use one of the MQOO_INPUT* options?
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
HeadOffice
PostPosted: Mon May 12, 2008 10:00 am    Post subject: All fixed Reply with quote

Newbie

Joined: 13 Mar 2008
Posts: 9

Yes, the queue opening flag was the secret.

Thank you very much.

I connect to the queue twice - once in browse mode and once in open mode. I browse for the message I'm after and then pass that to my function to get it off the queue. Works like a charm...
Back to top
View user's profile Send private message Send e-mail
bruce2359
PostPosted: Mon May 12, 2008 12:03 pm    Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9470
Location: US: west coast, almost. Otherwise, enroute.

Quote:
the queue opening flag was the secret.


Not so much a secret as well documented in the WMQ Application Programming Reference, under MQOPEN:

Options (MQLONG) – input
You must specify at least one of the following options:
MQOO_BROWSE
MQOO_INPUT_* (only one of these)
MQOO_INQUIRE
MQOO_OUTPUT
MQOO_SET
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
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 » Browsing a queue in C#
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.