|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
help with perl + MQBEGIN + MQGET and MQPUT options |
« View previous topic :: View next topic » |
Author |
Message
|
golemwashere |
Posted: Mon Dec 29, 2003 1:00 pm Post subject: help with perl + MQBEGIN + MQGET and MQPUT options |
|
|
Newbie
Joined: 29 Dec 2003 Posts: 8
|
Hello,
I'd like to write 2 scripts which should
1) read from a MQSeries queue (with wait unlimited) and write to an oracle DB
2) read from Oracle and write to a MQSeries queue
I would like to use both mq and oracle transactions
I'd like to do that in perl with MQSeries modules and DBI+ DBD::Oracle
I'd also like to use the plain syntax in MQ and not the OO one (the scripts will be mantained by people who required this).
some sample in c of my ideas could be:
http://www.fiendish.demon.co.uk/MQSeries/samples/write_to_oracle.c
my problem is I have some real troubles in using MQCMIT and also my MQCLOSE option is complaining with reason 0 and compcode 0
this is same working code I tried:
_________________________________________________
$coption = { 'ChannelName' => $channelname,
'TransportType' => 'TCP',
'ConnectionName' => '$connectionname',
};
$Hconn = MQCONNX($qmgr_name, { 'ClientConn' => $coption
}, $cc, $re);
$ObjDesc = {
ObjectName => $queuename,
};
$Hobj = MQOPEN($Hconn,$ObjDesc,$Options,$CompCode,$Reason);
$GetMsgOpts = {
Options => MQGMO_FAIL_IF_QUIESCING | MQGMO_SYNCPOINT | MQGMO_WAIT,
WaitInterval => MQWI_UNLIMITED,
};
$MsgDesc = {
CorrelId => $correlid,
Data => $data
};
$Buffer = MQGET($Hconn,$Hobj,$MsgDesc,$GetMsgOpts,$BufferLength,$CompCode,$Reason);
________________________________________________________
could anyone help me in providing syntax for the MQCONNECT, MQBEGIN
MQGET or MQPUT , MQCMIT options called in a perl script ?
Infinite thanks
Golem |
|
Back to top |
|
 |
bduncan |
Posted: Fri Jan 02, 2004 11:12 am Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
To find some perl examples, look in the software repository:
http://www.mqseries.net/pafiledb203/pafiledb.php?action=viewcat&id=1
Quote: |
my problem is I have some real troubles in using MQCMIT and also my MQCLOSE option is complaining with reason 0 and compcode 0
|
Last time I checked, getting zero meant that everything worked fine. Are you sure those calls aren't actually succeeding? _________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
Back to top |
|
 |
golemwashere |
Posted: Tue Jan 06, 2004 10:39 am Post subject: MQCLOSE |
|
|
Newbie
Joined: 29 Dec 2003 Posts: 8
|
for example,
I do an
Code: |
MQCLOSE($HConn,$ObjDesc,MQCO_NONE,$CompCode,$Reason) or die(" MQCLOSE failed compcode: $CompCode reason: $Reason");
|
and the script dies with CompCode 0 and Reason 0,
which should mean something was wrong... or not?
Thanks
Golem |
|
Back to top |
|
 |
bower5932 |
Posted: Tue Jan 06, 2004 10:44 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
I'd have to second what Brandon said. A compcode of 0 and a reason of 0 means it worked. Is there something else happening that makes you think it didn't work? |
|
Back to top |
|
 |
golemwashere |
Posted: Wed Jan 07, 2004 4:09 am Post subject: MQCLOSE dies |
|
|
Newbie
Joined: 29 Dec 2003 Posts: 8
|
Should'nt the MQCLOSE statement return a successful state code if executing properly?
all other statements (MQCONNECT, MQOPEN,etc...) never enter the die statement if successfully executing... |
|
Back to top |
|
 |
bduncan |
Posted: Wed Jan 07, 2004 11:44 am Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
Everytime I have written Perl MQ scripts, I haven't used the:
do this() or die();
convention.
I realize that is standard Perl, but I tend to do it in the following way (and it seems to work for me):
Code: |
MQCLOSE($HConn,$ObjDesc,MQCO_NONE,$CompCode,$Reason);
if($CompCode=0 && $Reason=0) then
##it was a success
else die("something went wrong");
|
The reason I do it this way is because on other statements like MQGET for instance, you want to test for a lot of different scenarios. So I would have a case statement or a bunch of elsifs testing the value of Reason:
Code: |
if($Reason=0) then success()
elsif($Reason=2033) print("no more messages")
elsif($Reason=2058) die("can't talk to QMGR)
etc...
|
_________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
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
|
|
|
|