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 » Browse & get partcular Msg for specific msgId in linux/C

Post new topic  Reply to topic
 Browse & get partcular Msg for specific msgId in linux/C « View previous topic :: View next topic » 
Author Message
sutanu
PostPosted: Tue May 24, 2005 7:27 am    Post subject: Browse & get partcular Msg for specific msgId in linux/C Reply with quote

Newbie

Joined: 22 Apr 2005
Posts: 9

Hi,

While I'm able to browse and get record sequentially from queue, but I'm unable to browse / get message from queue for specific message ID using C++ API in linux. Would appreciate any help to resolve the problem.

Following is a code snippet for browse_with_message_id



long len = 0;
delete []msg_buffer;
msg_buffer = 0;

mq_message.setMessageId((unsigned char*)lMsgId);
mq_message.useEmptyBuffer(msg_buffer, 0);

//Set gmo option.
gmo_option.setOptions(MQGMO_BROWSE_FIRST |
MQGMO_FAIL_IF_QUIESCING|MQGMO_CONVERT |
MQGMO_SYNCPOINT);

gmo_option.setMatchOptions(MQMO_MATCH_MSG_ID);

//Browse the message, if fail throws exception.
if(usr_queue.get(mq_message, gmo_option))
{
// Processing logic to get the data from the usr_queue object

}
else
{
// throws exception
}


FYI , the queue was connected with the following options :

open_option = MQOO_BROWSE+ MQOO_INQUIRE +
MQOO_FAIL_IF_QUIESCING + MQOO_INPUT_AS_Q_DEF ;
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
jefflowrey
PostPosted: Tue May 24, 2005 7:35 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Why are you trying to do this?

What is lMsgId defined as?

What reason code do you get back from get?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
sutanu
PostPosted: Tue May 24, 2005 10:50 am    Post subject: Reply with quote

Newbie

Joined: 22 Apr 2005
Posts: 9

lMsgId is defined as a char*. I've type casted it to (unsigned char*) as I've seen that the datatype of MQBYTE is unsigned char.

I want to view and remove the message based on specific message Id.

After the get operation i get reason code as 2033(MQRC_NO_MSG_AVAILABLE).
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
fjb_saper
PostPosted: Tue May 24, 2005 12:44 pm    Post subject: Reply with quote

Grand High Poobah

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

sutanu wrote:
lMsgId is defined as a char*. I've type casted it to (unsigned char*) as I've seen that the datatype of MQBYTE is unsigned char.

I want to view and remove the message based on specific message Id.

After the get operation i get reason code as 2033(MQRC_NO_MSG_AVAILABLE).
2033 is a good return code. It specifies that there is no message available on the queue that matches your options.

Enjoy
Back to top
View user's profile Send private message Send e-mail
sutanu
PostPosted: Tue May 24, 2005 8:30 pm    Post subject: Reply with quote

Newbie

Joined: 22 Apr 2005
Posts: 9

I agree that 2033 is a good return code.

The problem is that though there is a valid message with the same ID it is returning 2033 which should not be the case.

Regards
Sutanu
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
jefflowrey
PostPosted: Wed May 25, 2005 2:55 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

If it's not matching, you haven't set the id to match properly.

Use your code to create a new message. Use amqsbcg to dump both your message and the one you are trying to select. Compare the two to see what you're doing wrong.

Also - unless you're writing some sort of monitoring/management tool, you should not be doing what you're doing.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
sutanu
PostPosted: Wed May 25, 2005 8:52 pm    Post subject: Reply with quote

Newbie

Joined: 22 Apr 2005
Posts: 9

Thanks for your help.

I just changed the code as follow and everything works properly.

Thanks for all your help...

Regards
Sutanu


long len = 0;
delete []msg_buffer;
msg_buffer = 0;

/*-------------- changed as follow------------------*/
char* newMsgID = new char[24]; // mind 24 is specific as MQBYTE24
// consists of 24 characters

strcpy(newMsgID,lMsgId);

mq_message.setMessageId((const unsigned char*)newMsgID);

/*-------------- changed as follow------------------*/

mq_message.useEmptyBuffer(msg_buffer, 0);
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Browse & get partcular Msg for specific msgId in linux/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.