Author |
Message
|
nbh |
Posted: Sat Jul 23, 2005 1:02 am Post subject: Using Perl MQseries 1.23 to put a message on a remote queue |
|
|
Newbie
Joined: 23 Jul 2005 Posts: 2
|
|
Back to top |
|
 |
jefflowrey |
Posted: Sat Jul 23, 2005 3:39 am Post subject: Re: Using Perl MQseries 1.23 to put a message on a remote qu |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
nbh wrote: |
I am under the impression that I do not need a "MQ client" but that I can use Perl to put a message on a MQ queue.
|
This is not true. The MQ API for Perl require an MQClient to be installed on the machine, as they make an XS binding to the native libs.
This means that, not only do you need an MQ Client, you have to have a C compiler somewhere for the same platform, that you can use to build the module.
The perldoc for these modules is very good, and does contain a complete example - albeit spread out over a couple of different modules.
Basically, the perl API provides you two choices. One, the straight C API turned into perl functions. The other is the OO interface - and I would highly recommend this instead if you are not an MQ programmer.
For the OO interface, the connection information is passed to the constructor for the QueueManager object, as named hash values. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Nathan |
Posted: Mon Jun 05, 2006 6:38 am Post subject: |
|
|
 Acolyte
Joined: 15 Sep 2003 Posts: 52 Location: Rochester, NY
|
I know this topic is a bit old... But, I have the same question.
I have MQServer and Client installed and need to have a perl script use the Client to connect to another system's QManager so that I can check the status of Queues and Channels. Does anyone have a Client Connection sample code?
I keep getting 2058.
Thanks, |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jun 05, 2006 6:42 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
Nathan |
Posted: Mon Jun 05, 2006 6:52 am Post subject: |
|
|
 Acolyte
Joined: 15 Sep 2003 Posts: 52 Location: Rochester, NY
|
Did that. If I use the MQCONNX call or the MQSeries::QueueManager->new Object Oriented call, I get the same result. I have successfully used it against a local QManager by removing the client specific calls. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jun 05, 2006 7:14 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Can I see your QueueManager->new call? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Nathan |
Posted: Mon Jun 05, 2006 7:20 am Post subject: |
|
|
 Acolyte
Joined: 15 Sep 2003 Posts: 52 Location: Rochester, NY
|
Here it is...
$QMGR is set to the QManager name (Client channel is named the same)
$Connection is set to host.name.address(port)
Code: |
use MQSeries ;
use MQSeries::QueueManager ;
# Initiate QManager
$qmgr = MQSeries::QueueManager->new
(
QueueManager => $QMGR,
ClientConn => {
ChannelName => $QMGR,
TransportType => 'TCP',
ConnectionName => $Connection
},
AutoConnect => 0,
ConnectTimeout => 30,
Carp => \&ErrorLog,
) || die "Unable to instantiate MQSeries::QueueManager object\n";
# Connect to QManager
$qmgr->Connect() ;
$reason = MQReasonToText($qmgr->Reason()) ;
print " Reason: " . $reason . "\n" ;
print " Reason: " . $qmgr->Reason() . "\n" ;
# Disconnect QManager
$qmgr->Disconnect() ; |
|
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jun 05, 2006 7:22 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I think if you specify the QueueManager it always tries to use the server connection. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Nathan |
Posted: Mon Jun 05, 2006 7:28 am Post subject: |
|
|
 Acolyte
Joined: 15 Sep 2003 Posts: 52 Location: Rochester, NY
|
If I delete the QManager setting, I get the same error.
Here is the MQCONNX call where I get the same 2058 error.
Code: |
use MQClient::MQSeries ;
$coption = {
ChannelName => $QMGR,
TransportType => 'TCP',
ConnectionName => $Connection
};
$Hconn = MQCONNX($QMGR, { 'ClientConn' => $coption,
}, $cc, $Reason);
print " Reason: " . MQReasonToText($Reason) . "\n" ;
print " Reason: $Reason\n" ;
MQDISC($Hconn,$CompCode,$Reason);
|
This is pulled right from the MQSeries.pm |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jun 05, 2006 7:39 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
When you built the module, did it build clean? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Nathan |
Posted: Mon Jun 05, 2006 8:17 am Post subject: |
|
|
 Acolyte
Joined: 15 Sep 2003 Posts: 52 Location: Rochester, NY
|
Thanks. I think I figured it out. I knew my code was right. I went and looked at what was compiled (I didn't work here when it was compiled). It is still version 1.17! I will attempt to get it up to 1.23 first.  |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Jun 05, 2006 8:21 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Ah, yeah. That's a big thing.
BEFORE YOU BUILD 1.23! Make sure that you have set up an MQSERVER environment variable in your shell that will run the commands.
This will ensure that all the tests for the MQClient pass, and it will be easier to build and install the module. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
zpat |
Posted: Thu Jun 16, 2011 3:26 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Ahha - That's what I need to know ....! Thanks Jeff
Finally got a Perl/MQ program to work. A bit like having to build your own airplane from a kit (some brave/foolish people do this..) |
|
Back to top |
|
 |
|