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 Msg by MSGID; Problem storing MsgId in MQMD

Post new topic  Reply to topic
 Browse Msg by MSGID; Problem storing MsgId in MQMD « View previous topic :: View next topic » 
Author Message
ScottieMQ
PostPosted: Mon Aug 15, 2005 11:27 am    Post subject: Browse Msg by MSGID; Problem storing MsgId in MQMD Reply with quote

Newbie

Joined: 15 Nov 2004
Posts: 3

Hello All,
I know that a knowledgeable C programmer will look at this problem and think it is trivial. Unfortunately, I am not a C programmer.

This is my problem.

I am modifying the IBM Sample browse program (amqsbcg0.c) on an AIX server running MQSeries v5.3.0.7. I am compiling and linking it as a client application using the VisualAge C Compiler for AIX. I have messages that are written to a local queue, which I am browsing, whose Message ID's are created by MQSeries (e.g. AMQ..servername..sequence number for uniqueness).

A sample Message ID in Hex as I see it displayed by the browse application is:
414D512051503054314131535620202042FB79A920000202

Since there is that null character (e.g. 00) in byte 22, it seems like coding:

printf("\n MsgId : X'");

for (i = 0 ; i < MQ_MSG_ID_LENGTH ; i++)
printf("%02X",MDin->MsgId[i] );

printf("'");

to produce the 24 byte hex string is the only way to capture the entire MsgId from what I have discovered is stored in some kind of Array data structure (e.g. MsgId[x]). Any other "flavor" of printf that I have tried truncates the last three bytes since I guess that it is treating the null character as end of string. Without those 3 bytes it is not possible to browse a specific message.

If I want to call the modified browse application and pass it 3 parameters
(Queue Name, Queue Manager Name, the above 24 byte haxadecimal MsgId string) so that I can read 1 specific message by MsgId:

1. GetMsgOpts.MatchOptions = MQMO_MATCH_MSG_ID;
2. memcpy(MsgDesc.MsgId, argv[3], sizeof(MQBYTE24) );

then is there a way of coding the memcpy command above or some other command that I can code that will store the third parameter (e.g the 24 byte hex MsgId string) properly in the MQMD MsgId field so that I browse the proper message?

Thanking you in advance for your support.
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Mon Aug 15, 2005 11:53 am    Post subject: Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3264
Location: London, ON Canada

Hi,
Quote:
24 byte haxadecimal MsgId string

That is exactly your problem, MsgID, CorrelID, GroupID, etc.. are byte arrays and not string arrays.

As you noted, the MsgID contains nulls, therefore, there is no way to pass it on the command line. You need to pass the 48-bye 'hexadecimal' representation of the MsgID as a parameter to the program.
i.e. 414D512051503054314131535620202042FB79A920000202
Then in your program it will convert the 48-byte hexedecimal number to the proper 24-byte MsgID.

Other than a programming exercise, what are you trying to accomplish because the wheel (i.e. your tool) may have already been invented.

Regards,
Roger Lacroix
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
ScottieMQ
PostPosted: Mon Aug 15, 2005 12:30 pm    Post subject: memcpy command failure Reply with quote

Newbie

Joined: 15 Nov 2004
Posts: 3

Hello Roger,

Thanks for your response. No, I do not make it a habit of re-inventing the wheel as I have downloaded many an IBM Support Pac for MQSeries and made other little discoveries poking around on the web.

It is just that I have only been working in the distributed environment for 4 years and am thus wanting to improve my skill set such as learning shell scripting, c, and any other bits and pieces that I feel would leverage my ability to support the applications developers and my customers.

The problem that I have is that the memcpy command as I have coded it is taking the 48 character string that is the hex MsgId which I am passing as the third argument and is stripping off the first 24 characters and storing them in the MQMD MsgId which is not going to produce the results that I am looking for.

Hence, I am just looking for a "flavor" of memcpy or some other comparable command that will store the entire 48 character string that I supply as input properly into the MQMD MSgId field so that I can retrieve the message whose message ID is equal to what I am passing the program.

Regards.

ScottieMQ
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Aug 15, 2005 12:36 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You will have to reconvert the hex characters to byte values.

If you look at the code that converts it from bytes to hex, it may help you convert back.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Aug 15, 2005 12:40 pm    Post subject: Reply with quote

Grand High Poobah

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

Check if there is such a function as the java "decode" method

like Integer.decode("0x0fa5...")

or else use simple logic
get array position {0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f} for first char
multiply by 16 and add array position second char.
Set value to byte.

Enjoy
Back to top
View user's profile Send private message Send e-mail
tkane
PostPosted: Tue Aug 16, 2005 8:52 am    Post subject: Reply with quote

Voyager

Joined: 23 Dec 2002
Posts: 82
Location: Kansas City

I think what you want is something similar to:
Code:

    /*****************************************************************/
    /* MsgId is not null terminated, so print one char at a time (if */
    /* the char is printable). Similarly for other strings below.    */
    /*****************************************************************/
    for(i=0;i<24;i++) printf("%c",(isprint(md->MsgId[i]) \
                                   ? md->MsgId[i] : '.') );
    printf("\n");


This is a paste from a program called mget.c that's buried in a support PAC MA1C.
http://www-1.ibm.com/support/docview.wss?rs=171&uid=swg24000080&loc=en_US&cs=utf-8&lang=en
It's one of my favorite MQ programs. I probably run it most days on Unix or Linux or MVS.

Note that on HP-UX where the default for a "char" is signed char you'll get odd results when the high order bit is on. The fix for that is to cast the char to MQBYTE
Code:
pbuff = (MQBYTE *)pbuffer;


Good Luck on this. I've learned C slowly over the years and am not the best.

Tom
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » Browse Msg by MSGID; Problem storing MsgId in MQMD
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.