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 » [Solution] Read MQMD with Perl MQSeries

Post new topic  Reply to topic
 [Solution] Read MQMD with Perl MQSeries « View previous topic :: View next topic » 
Author Message
WillH
PostPosted: Wed Jun 15, 2005 7:32 am    Post subject: [Solution] Read MQMD with Perl MQSeries Reply with quote

Novice

Joined: 15 Jun 2005
Posts: 23

I'm having trouble figuring out how to access data in $MsgDesc from the following call:

$Buffer = MQGET($Hconn,$Hobj,$MsgDesc,$GetMsgOpts,$BufferLength,$CompCode,$Reason);

I looked through the sample getput.pl but it doesn't include perusing $MsgDesc.

According to the docs, it's a hash reference, but I don't know the name of the hash table it points to. I think this is what I need.

Any ideas?


Last edited by WillH on Wed Jun 15, 2005 8:33 am; edited 1 time in total
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jun 15, 2005 7:40 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

According to the documentation,
Quote:
The $MsgDesc and $GetMsgOpts values are hash references. The $MsgDesc will be populated with the MQMD structure returned by the MQGET call.


So, the keys of the $MsgDesc hash are the names of the fields in the MQMD. Like, e.g $MsgDesc{'Format'}.

It's not spelled out as clearly as it might be in the perldoc for MQSeries. But MQSeries::Message has some more specific examples - even though it's for the OO interface instead of the plain API interface.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
WillH
PostPosted: Wed Jun 15, 2005 8:32 am    Post subject: [Solution] Read MQMD with Perl MQSeries Reply with quote

Novice

Joined: 15 Jun 2005
Posts: 23

$MsgDesc is not a hash itself - it's a hash reference. After some more tinkering and research, here's how to print the keys and values from a hash reference. You must use %$<hashrefname> and not just $<hashrefname>. Weird.

Code:

   $Buffer = MQGET($Hconn,$Hobj,$MsgDesc,$GetMsgOpts,$BufferLength,$CompCode,$Reason);
   
   foreach $key (keys %$MsgDesc)
   {
      print "$key: %$MsgDesc->{$key}\n";
   }


The output from this is:
Code:

PutTime: %05315565
ReplyToQ: %
GroupId: %
UserIdentifier: %mqm
Encoding: %273
ApplIdentityData: %
BackoutCount: %0
Format: %MQHRF2
MsgFlags: %0
ApplOriginData: %
PutApplName: %
MsgType: %8
MsgSeqNumber: %1
CodedCharSetId: %819
AccountingToken: %40000
Offset: %0
CorrelId: %
ReplyToQMgr: %WMQPQM01
Persistence: %1
PutDate: %20050614
OriginalLength: %-1
PutApplType: %28
Expiry: %-1
PutApplName: %
MsgType: %8
MsgSeqNumber: %1
CodedCharSetId: %819
AccountingToken: %40000
Offset: %0
CorrelId: %
ReplyToQMgr: %WMQPQM01
Persistence: %1
PutDate: %20050614
OriginalLength: %-1
PutApplType: %28
Expiry: %-1
Version: %2
MQMD_DEFAULT: %
Priority: %4
Feedback: %0
Report: %0
MsgId: %AMQ WMQPQM01    B¬UÞ â„¢
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jun 15, 2005 8:40 am    Post subject: Re: [Solution] Read MQMD with Perl MQSeries Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

WillH wrote:
$MsgDesc is not a hash itself - it's a hash reference. After some more tinkering and research, here's how to print the keys and values from a hash reference. You must use %$<hashrefname> and not just $<hashrefname>. Weird.


That's not weird, that's perl. And it's not what you need to do - but the perlref manpage might help you understand.

I made a slight typo, which probably lead you down the path. Instead of saying $MsgDesc{'Format'} or etc, you need to say $MsgDesc->{'Format'}.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
WillH
PostPosted: Wed Jun 15, 2005 8:43 am    Post subject: Reply with quote

Novice

Joined: 15 Jun 2005
Posts: 23

Wow, yeah that works even more beautifuller.

Code:

   foreach $key (keys %$MsgDesc)
   {
      print "$key: $MsgDesc->{$key}\n";
   }
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 » [Solution] Read MQMD with Perl MQSeries
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.