Author |
Message
|
ddm |
Posted: Tue Nov 09, 2004 7:45 pm Post subject: Matching by MessageIDs |
|
|
Apprentice
Joined: 17 Nov 2003 Posts: 40
|
I have this code that allows the user to use the MessageID or CorrelationID when retrieving MQ messages. I can't make it to work when I use MatchByMessageID. On the other hand, it always works when I use the correlationID.
Here's the pseudo code:
mqMessage = new MQMessage();
if(matchOptions == MatchMessageOption.MATCH_BY_CORRELLATION_ID)
{mqMessage.CorrelationId = correlationID;
}
else if(matchOptions == MatchMessageOption.MATCH_BY_MESSAGE_ID)
{
mqMessage.MessageId = messageID;
}
MQGetMessageOptions mqGetMessageOptions = new MQGetMessageOptions();
mqGetMessageOptions.Options = MQC.MQGMO_WAIT;
mqGetMessageOptions.MatchOptions = matchOptions;
queue.Get(mqMessage, mqGetMessageOptions);
//---> it hangs on queue.Get when the MatchOption is MATCH_BY_MESSAGE_ID
***Edit Notes
mqMessage.MessageId = messageID; was originally mqMessage.MessageId = correlationID;
***
Last edited by ddm on Wed Nov 10, 2004 10:06 am; edited 1 time in total |
|
Back to top |
|
 |
RogerLacroix |
Posted: Tue Nov 09, 2004 9:45 pm Post subject: |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
Well, is there a message in the queue with a matching MsgID? Sounds like there is not.
Regards,
Roger Lacroix _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Nov 10, 2004 3:32 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I think if you read the code you have posted, you will see the problem. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
bower5932 |
Posted: Wed Nov 10, 2004 6:02 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
Good eyesight! I would have never spotted it if you hadn't said something, and it still took me five minutes.
For what it is worth, there are a couple of program (mqreqro, mqsrvro) out at:
http://www.developer.ibm.com/tech/sampmq.html
They also mess with report options. You might find them useful. |
|
Back to top |
|
 |
ddm |
Posted: Wed Nov 10, 2004 10:04 am Post subject: |
|
|
Apprentice
Joined: 17 Nov 2003 Posts: 40
|
jefflowrey wrote: |
I think if you read the code you have posted, you will see the problem. |
I see what you're saying. I am assigning the variable correlationID to the MessageID property of the mqMessage.
Actually, in my actual code the correlationID is a parameter to a method where I pass it a value of either the correlationID or the messageID byte array
I apologize for the confusion. I'll edit my original post.
Anything else comes to mind why the MatchByMessageID doesn't work?
Thanks! |
|
Back to top |
|
 |
ddm |
Posted: Wed Nov 10, 2004 4:28 pm Post subject: |
|
|
Apprentice
Joined: 17 Nov 2003 Posts: 40
|
I already upgraded to CSD08 and still cannot make MatchByMessageID to work. What am i missing?
If you guys have sample code / getmessageoptions that I can use, I'd truly appreciate it. - Thanks!
On the above sample, (mqreqro, mqsrvro) it does not do a get using MatchByMessageID. It just gives the option to the user whether the system generates a new MessageID or not - which is included in the reply. |
|
Back to top |
|
 |
JT |
Posted: Wed Nov 10, 2004 4:50 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
as Roger wrote: |
Well, is there a message in the queue with a matching MsgID? Sounds like there is not. |
Can you confirm that there is a message(s) on the queue with the msgid(s) you expect? |
|
Back to top |
|
 |
ddm |
Posted: Fri Nov 12, 2004 9:22 am Post subject: |
|
|
Apprentice
Joined: 17 Nov 2003 Posts: 40
|
JT wrote: |
as Roger wrote: |
Well, is there a message in the queue with a matching MsgID? Sounds like there is not. |
Can you confirm that there is a message(s) on the queue with the msgid(s) you expect? |
In my actual code, I first do a put() of the message, sleep a while then do a get(). There was no error on the put() so I am sure that there is a message out there with the same messageID. I also have an 'UNLIMITED' wait on the get.
Thanks! |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Nov 12, 2004 9:57 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
ddm wrote: |
In my actual code, I first do a put() of the message, sleep a while then do a get(). There was no error on the put() so I am sure that there is a message out there with the same messageID. |
Except, of course, if you're in a transaction of some sort, and you haven't committed yet.
Or if you are doing the wrong things with message IDs and aren't setting them to the values you think you are setting them to. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
bower5932 |
Posted: Fri Nov 12, 2004 10:17 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
Run the amqsbcg program against the queue. It will browse the messages on the queue (if there are any) and it will dump the message id and correlation id out in hex. It might point to something that has been overlooked. |
|
Back to top |
|
 |
JT |
Posted: Fri Nov 12, 2004 10:25 am Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
Quote: |
I can't make it to work when I use MatchByMessageID. On the other hand, it always works when I use the correlationID. |
Can we assume your (message id) logic is identical to the method for retrieving by correlation id?
Is there an expiry set on the message?
What reason code are you receiving (2033)?
Quote: |
In my actual code, I first do a put() of the message, sleep a while then do a get(). There was no error on the put() so I am sure that there is a message out there with the same messageID. I also have an 'UNLIMITED' wait on the get.
|
Why are you setting an unlimited getwait interval if you had previously written the message to the queue and then went into a delay? |
|
Back to top |
|
 |
|