PayPal is the easiest way to receive money online. Get one now or Click here to sign up. Sign up for PayPal and start accepting credit card payments instantly.

How to peek message MSMQ using perl

use Win32::OLE;
use strict;
my %getInbox;
my $msmq_path = "direct=os:MSMQ-Server\\Private\$\\test";
my $objInfo = Win32::OLE->new('MSMQ.MSMQQueueInfo');
my $objMsg = Win32::OLE->new('MSMQ.MSMQMessage');

$objInfo->{FormatName}= $msmq_path;
#$objMsg->{Body}= "test";
#$objMsg->{Label}= '12005I112';
my $objQue=$objInfo->open(1,0);
$getInbox{message} = $objQue->PeekCurrent(0,1,1,10);
$getInbox{info} = $objQue->Receive() if (defined($getInbox{message}));
while (defined($getInbox{info}))
{
print $getInbox{info}->{Body},"\n";
print $getInbox{info}->{Label},"\n";
$getInbox{message} = $objQue->PeekNext(0,1,1,10);
last if (!(defined($getInbox{message})));
$getInbox{info}=$objQue->Receive()
}

$objQue->Close;

1 comment:

Jack said...

Very helpful. Been looking all over for MSMQ w/ Perl in recent days. Thanks for your post!

WebProNews Feed

eWeek - RSS Feeds

HowtoForge - Howtos and Tutorials

The Register

PayPal is the easiest way to receive money online. Get one now or Click here to sign up. Sign up for PayPal and start accepting credit card payments instantly.