Author |
Message
|
HeadOffice |
Posted: Wed Apr 23, 2008 12:24 pm Post subject: Browsing a queue in C# |
|
|
 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 |
|
 |
jefflowrey |
Posted: Wed Apr 23, 2008 12:31 pm Post subject: |
|
|
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 |
|
 |
HeadOffice |
Posted: Wed Apr 23, 2008 12:42 pm Post subject: I do... |
|
|
 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 |
|
 |
PeterPotkay |
Posted: Wed Apr 23, 2008 5:29 pm Post subject: |
|
|
 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 |
|
 |
HeadOffice |
Posted: Mon May 12, 2008 10:00 am Post subject: All fixed |
|
|
 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 |
|
 |
bruce2359 |
Posted: Mon May 12, 2008 12:03 pm Post subject: |
|
|
 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 |
|
 |
|