|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Help returning DataLength with perl mqseries api |
« View previous topic :: View next topic » |
Author |
Message
|
Smithy |
Posted: Sun Jan 09, 2005 10:47 am Post subject: Help returning DataLength with perl mqseries api |
|
|
Newbie
Joined: 09 Jan 2005 Posts: 3
|
Hi,
I am new to mqseries and have almost no experience programming to the API. I have had success pulling data from the MQMD headers, but what I really need to get is the value of the DataLength from the MQGET call. Unfortunately I have been unable to do so using perl. The message I get is always:
Code: |
Usage: MQServer::MQSeries::MQGET(Hconn, Hobj, MsgDesc, GetMsgOpts, Length, CompCode, Reason) at ./QueueControl.pl line 131
|
Here is how I am trying to return the value:
Code: |
my $GetMsgDesc = {};
my $GetMsgOptions = MQGMO_WAIT | MQPMO_SYNCPOINT | MQGMO_FAIL_IF_QUIESCING;
my $GetMsgOpts =
{
Options => $GetMsgOptions,
WaitInterval => 5000, ## in milliseconds (5 secs)
};
# my $Buffer = MQGET($Hconn, $HobjIP, $GetMsgDesc, $GetMsgOpts, $BufferLength, $CompCode, $Reason);
MQGET($Hconn, $HobjIP, $GetMsgDesc, $GetMsgOpts, $BufferLength, $CompCode, $Reason, $DataLength);
print "Get msgid is from MQMD $GetMsgDesc->{Format}\n";
print "CompCode = $CompCode\n";
print "Reason = $Reason\n";
print "DataLength = $datalength\n";
|
When I don't reference $DataLength, everything works as it should. Above error when I do.
Any help on this would be appreciated. The goal of this script will be to pull the DataLength value off of each message in the queue and add them up, so I will no just how large the actual q file object is at a given point in time.
Thanks
Smithy |
|
Back to top |
|
 |
clindsey |
Posted: Sun Jan 09, 2005 5:37 pm Post subject: |
|
|
Knight
Joined: 12 Jul 2002 Posts: 586 Location: Dallas, Tx
|
Smithy,
The verbs do not map exactly the same in perl as they do in C.
Try perdol mqseries to get the syntax. You can get the length of the scalar 'buffer' after the MQGet to learn the DataLength.
Give this a try:
Code: |
use MQSeries;
use strict;
my $CompCode;
my $Reason;
my $queue = $ARGV[0];
my $qmgr = $ARGV[1];
my $Hconn = MQCONN($qmgr, $CompCode, $Reason);
print"MQCONN: $Reason\n";
my $Options = MQOO_INPUT_AS_Q_DEF | MQOO_FAIL_IF_QUIESCING;
my $ObjDesc = { ObjectName => $queue };
my $Hobj = MQOPEN($Hconn,$ObjDesc,$Options,$CompCode,$Reason);
print"OPEN: $Reason\n";
my $GetMsgDesc = {};
my $GetMsgOpts = { Options => MQGMO_FAIL_IF_QUIESCING | MQGMO_NO_WAIT, MatchOptions => MQMO_NONE };
my $bufferlen=100;
my $MsgDesc = {MsgId=>MQMI_NONE,CorrelId=>MQCI_NONE,Encoding=>MQENC_NATIVE,CodedCharSetId=>MQCCSI_Q_MGR};
my $Buff = MQGET($Hconn, $Hobj, $MsgDesc, $GetMsgOpts, $bufferlen, $CompCode, $Reason);
my $datalength = length($Buff);
print"MQGET: $Reason\n";
print "DataLength = $datalength\n";
|
Charlie |
|
Back to top |
|
 |
Smithy |
Posted: Mon Jan 10, 2005 9:23 am Post subject: Thanks! |
|
|
Newbie
Joined: 09 Jan 2005 Posts: 3
|
Charlie,
Thanks for the heads up. I kind of thought that the perl syntax may have been a little different, especially since I didn't really see any references to DataLength in the CPAN mqseries documentation. Your suggestion worked wonderfully.
However...
I'm now faced with the problem that I must actually read each message in it's entirety to return the DataLength. I had hoped the value might be encased
somewhere in the message header itself. There is a key value pair in MQMD called OriginalDataLength. I thought that getting that value for each message and doing a running sum would get me close to the true size of the q file, but I believe that means I have to read the entire message just to get that value, which would put a performance strain on the application.
To redirect my question somewhat, is there any way that I can just read in the message header info itself without pulling in the whole message? Perhaps reading into a certain byte offset to get/browse that portion of the message and stop.
Again, keep in mind I'm really just a glorified operator, I'm not a developer so if I'm missing something blindingly simple don't hold it against me. If all else fails I supose I can just take current queuedepth based on an average message size and make decisions based on that, but it seems there should be a more accurate way of tracking how much data one actually has in a queue.
Cheers and thanks again for the help!
Pat Smith |
|
Back to top |
|
 |
clindsey |
Posted: Mon Jan 10, 2005 9:49 am Post subject: |
|
|
Knight
Joined: 12 Jul 2002 Posts: 586 Location: Dallas, Tx
|
Pat,
I don't think perldoc reflects this but it seems $bufferlen does get updated to reflect the message size. For your purposes, you can set bufferlen to 0 prior to the MQGET. The MQGET will fail with reason=2080 (truncated message) and no message data is actually read. $bufferlen though now contains the actual message length.
Charlie |
|
Back to top |
|
 |
Smithy |
Posted: Mon Jan 10, 2005 10:49 am Post subject: Thanks Again!!! |
|
|
Newbie
Joined: 09 Jan 2005 Posts: 3
|
Charlie,
Yep, that was the ticket. I'm off to do some stress testing now. Incidently I had entered a PMR with IBM support regarding the same issue and obviously they came up with the same response as you. I guess you're a master for a reason eh? Thank you for the help, I hope when I get this mess of a script cleaned up I can submit it to the perl repo...
Pat |
|
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
|
|
|
|