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 » Get Message using matcahing message ID does not really works

Post new topic  Reply to topic
 Get Message using matcahing message ID does not really works « View previous topic :: View next topic » 
Author Message
crayon_coco
PostPosted: Wed Apr 13, 2005 8:49 pm    Post subject: Get Message using matcahing message ID does not really works Reply with quote

Apprentice

Joined: 08 Oct 2003
Posts: 33

Hi
i have a method that will browse the message with the matching Message ID, it works find when i pass in a valid message id, when i pass in an array of 24 bytes with any value, it will still return me a message, how do i avoid the get to get message when i in this array without any value

below is my code, i have already set the get message option to MQC.MQMO_MATCH_MSG_ID

public void Browse(string queueName, byte[] messageID)
{
if(messageID != null)
{
queue = queueManager.AccessQueue (queueName,MQC.MQOO_BROWSE + MQC.MQOO_INQUIRE + MQC.MQOO_FAIL_IF_QUIESCING + MQC.MQOO_INPUT_SHARED);
MQGetMessageOptions queueGetMessageOptions = new MQGetMessageOptions();
queueGetMessageOptions.Options += MQC.MQGMO_BROWSE_FIRST + MQC.MQMO_MATCH_MSG_ID;
try
{
MQMessage queueMessage = new MQMessage();
queueMessage.MessageId = messageID;
queue.Get(queueMessage,queueGetMessageOptions);
this.message = queueMessage.ReadString queueMessage.MessageLength);
this.isExist = true;
this.isCompleted = true;
}
catch(MQException exp)
{
if(exp.Reason==MQC.MQRC_NO_MSG_AVAILABLE)
{
this.errorMessage = "Message Not Available";
this.isCompleted = true;
}
else
{
this.isCompleted = false;
throw new Exception(exp.ToString());
}
}
}
else
{
throw new Exception("MQ Message Data error : Null Message ID not allowed ");
}
}
Back to top
View user's profile Send private message
mqmhr
PostPosted: Wed Apr 13, 2005 10:06 pm    Post subject: Reply with quote

Centurion

Joined: 28 Dec 2004
Posts: 105

Crayon_Coco, if I think I understand your question correctly,

Change the if condition to (messageID!= null AND messageID != MQC.MQMI_NONE)

When the message id is not assigned any value before the Browse method call, the if condition will return false and so no message would be got from the queue.
Back to top
View user's profile Send private message
crayon_coco
PostPosted: Wed Apr 13, 2005 11:37 pm    Post subject: Reply with quote

Apprentice

Joined: 08 Oct 2003
Posts: 33

HI,

i have tried it out but it didn't work.
i got the first message in the queue, what i want is if i pass in a array of bytes without values, it should not get the message at all,
i tried to do a loop the the array and convert it into string and i get a string of 0000000000000000000000000000000000000


Thanks
Coco
Back to top
View user's profile Send private message
Nigelg
PostPosted: Thu Apr 14, 2005 1:02 am    Post subject: Reply with quote

Grand Master

Joined: 02 Aug 2004
Posts: 1046

The string of all NULLs in the MsgId is MQC.MQMI_NONE, and matches all MsgId's, so your statement is wrong.
Quote:
if i pass in a array of bytes without values, it should not get the message at all

If you do this you will get any msg
Back to top
View user's profile Send private message
Nigelg
PostPosted: Thu Apr 14, 2005 1:03 am    Post subject: Reply with quote

Grand Master

Joined: 02 Aug 2004
Posts: 1046

BTW, try to avoid making the title of a post 'SOMETHING does not work', until you are sure that is is not your own fault.
Back to top
View user's profile Send private message
woodoo2k
PostPosted: Thu Apr 14, 2005 5:46 am    Post subject: Reply with quote

Apprentice

Joined: 07 Feb 2005
Posts: 28
Location: USA

Hi Cryon_coco,
Try removing MQGMO_BROWSE_FIRST and then run your program.
It seems due to this options, MQSeries is fetching first message from the queue even when MSGID is not matched.
Back to top
View user's profile Send private message Yahoo Messenger
elvis_gn
PostPosted: Thu Apr 21, 2005 8:58 pm    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hey,

For ur browse problem try something like this

status = 0;
if (status == 0) {
gmo.options = MQC.MQGMO_BROWSE_FIRST;
gmo.waitInterval = MQC.MQWI_UNLIMITED;
} else {
gmo.options = MQC.MQGMO_BROWSE_NEXT;
gmo.waitInterval = MQC.MQWI_UNLIMITED;
}
status = 1;
removeQueue.get(message, gmo);

This way u'll browse the first message first time and then always next.

About the messageId, i hope the problem is not that ur not fetching the messageId from the queue message properly....the messageId in the queue cannot be retrieved as a string...
It is a character array....
Give print statements first to see what are the messageId's ur comparing..
Back to top
View user's profile Send private message Send e-mail
fjb_saper
PostPosted: Thu Apr 21, 2005 9:05 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

elvis_gn wrote:

....
About the messageId, i hope the problem is not that ur not fetching the messageId from the queue message properly....the messageId in the queue cannot be retrieved as a string...
It is a character array....
Give print statements first to see what are the messageId's ur comparing..


Sorry but neither MessageId nor CorrelationID are a char array. They are byte arrays: byte[] !!

A char may limit the value, a byte does not.

Enjoy
Back to top
View user's profile Send private message Send e-mail
elvis_gn
PostPosted: Thu Apr 21, 2005 9:40 pm    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Sorry my mistake

Yes they are byte arrays
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Get Message using matcahing message ID does not really works
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.