|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
[Solution] Read MQMD with Perl MQSeries |
« View previous topic :: View next topic » |
Author |
Message
|
WillH |
Posted: Wed Jun 15, 2005 7:32 am Post subject: [Solution] Read MQMD with Perl MQSeries |
|
|
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 |
|
 |
jefflowrey |
Posted: Wed Jun 15, 2005 7:40 am Post subject: |
|
|
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 |
|
 |
WillH |
Posted: Wed Jun 15, 2005 8:32 am Post subject: [Solution] Read MQMD with Perl MQSeries |
|
|
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 |
|
 |
jefflowrey |
Posted: Wed Jun 15, 2005 8:40 am Post subject: Re: [Solution] Read MQMD with Perl MQSeries |
|
|
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 |
|
 |
WillH |
Posted: Wed Jun 15, 2005 8:43 am Post subject: |
|
|
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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|