March 06, 2007

perl mqseries activex

Here is a Perl script for acessing MQ series interface through the ActiveX interface using the MQAX200.dll. It requires having the MQ Series client installed on the machine running this script. And perl, or VA2. I looked at MQSeries for perl, but it requires a compiling using MAKE, and including the channel string that you're connecting to before compliation. I wanted a version I could distribute to VA2 users, so compiling wasn't an option. So I put together this short one using Win32::OLE. The only hard part seemed to be finding the ProgIds of the ActiveX controls, which were published hardly anywhere and I resorted to searching through the registry. Of course, once you have a handle to the MQAX interface you can do just about anything through MQ, in good old Perl. IBM Redbooks have some more info. I used it for graphing the depth of a MQ Series queue used for sending XML transactions to Siebel. By graphing the depth over time the transaction flow rate could be determined easily. Of course, written as a VA2 Statistic.
use Win32::OLE;

my $qmname = 'QM_hdfsccdrwp1';
my $qname = 'JavaQueue';

my $MqS =  Win32::OLE->new("MQAX200.MQSession");
my $oQueueManager = Win32::OLE->new("MQAX200.MQQueueManager");
my $oRequestQueue = Win32::OLE->new("MQAX200.MQQueue");

$oQueueManager = $MqS->AccessQueueManager($qmname);
warn "Error: " . Win32::OLE->LastError if Win32::OLE->LastError != 0; 
$oRequestQueue = $oQueueManager->AccessQueue($qname, 8 + 32);

$retval = $oRequestQueue->CurrentDepth;
Posted by choppen5 at 10:44 PM