Author |
Message
|
sutanu |
Posted: Tue May 24, 2005 7:27 am Post subject: Browse & get partcular Msg for specific msgId in linux/C |
|
|
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 |
|
 |
jefflowrey |
Posted: Tue May 24, 2005 7:35 am Post subject: |
|
|
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 |
|
 |
sutanu |
Posted: Tue May 24, 2005 10:50 am Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Tue May 24, 2005 12:44 pm Post subject: |
|
|
 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 |
|
 |
sutanu |
Posted: Tue May 24, 2005 8:30 pm Post subject: |
|
|
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 |
|
 |
jefflowrey |
Posted: Wed May 25, 2005 2:55 am Post subject: |
|
|
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 |
|
 |
sutanu |
Posted: Wed May 25, 2005 8:52 pm Post subject: |
|
|
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 |
|
 |
|