ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Installation/Configuration Support » Connecting to MQ using PHP

Post new topic  Reply to topic
 Connecting to MQ using PHP « View previous topic :: View next topic » 
Author Message
eriben
PostPosted: Tue Nov 01, 2011 12:49 pm    Post subject: Connecting to MQ using PHP Reply with quote

Newbie

Joined: 01 Nov 2011
Posts: 4

Is there anyone out there who successfully is using PHP/Linux to connect to MQ? For days I have desperately been trying to get this to work but to no avail. IF there's anyone out there who is doing this, how?

As I see it there's two extensions to use:
a) mqseries -> a thin wrapper to the C API
b) SAM 1.1.0 -> taking a more general approach

I've tried both but for a) I am able to do MQCONNX successfully, but not MQOPEN and for b) I am not getting past the MQCONN stage. I've tried both the 7 and the 6 Client. Our server is running 6.0.0.0.

Note; we've successfully been connecting to the server using .NET for years.

So this is what I've done so far:

1. Installed the MQClient from RPM packages
2. Installed IA94/XMS
3. Succesfully built the sam_xms.so extension and included that in my php.ini
4. Successfulyl built mqseries.so extension and included that as well.
5. Successfully been running the Samples from the mq client installation (amqsputc and amqsgetc) and been passing messages back and forth.

Using the mqseries PECL extension this is the error I get:

MQOPEN failed; CompCode:2 Reason:2044 Text:2044

Using the SAM PECL extension I get this instead:

<--SAMConnection.SetDebug()
-->SAMConnection.Connect()
-->SAMConnection.Create(proto=wmq:client)
SAMConnection.Create() get_cfg_var() ""
SAMConnection.Create() calling factory - SAM/sam_factory_xms.php
SAMConnection.Create() rc = SAMXMSConnection
<--SAMConnection.Create()
SAMConnection.Connect() connection created for protocol wmq:client
SAMConnection.Connect() connect failed (208) Unable to create XMS connection!
<--SAMConnection.Connect() rc=
-->SAMConnection.IsConnected()
SAMConnection.IsConnected() isconnected failed (208) Unable to create XMS connection!
<--SAMConnection.IsConnected() rc=
Connection failed (208) Unable to create XMS connection!

Neither of these errors generates anything in /var/mqm/errors...

Here's my sample code for mqseries:

Code:
    mqseries_conn('MQED', $conn, $comp_code, $reason);
    if ($comp_code !== MQSERIES_MQCC_OK) {
        printf("<br>MQCONNX failed; Connx CompCode:%d Reason:%d Text:%s<br>\n", $comp_code, $reason, $reason);
        exit;
    }
    else
    {
       printf("<br>MQCONNX successful: Connx CompCode:%d Reason:%d Text:%s<br>\n<br>", $comp_code, $reason, $reason);
    }

   $mqods = array('ObjectName'=>'MYPUTQUEUE');
   mqseries_open($conn, $mqods,
              MQSERIES_MQOO_INPUT_AS_Q_DEF | MQSERIES_MQOO_FAIL_IF_QUIESCING | MQSERIES_MQOO_OUTPUT,
              $obj, $comp_code,$reason);
             
             
    var_dump($mqods, $obj);
if ($comp_code !== MQSERIES_MQCC_OK) {
   printf("<br><br>MQOPEN failed; CompCode:%d Reason:%d Text:%s<br><br>",
         $comp_code,
         $reason,
         $reason);
}
else
{
   printf("<br><br>MQOPEN successful; CompCode:%d Reason:%d Text:%s<br><br>",
         $comp_code,
         $reason,
         $reason);
}


Here's the sample code using the SAM extension:

Code:
$conn->connect(SAM_WMQ_CLIENT, array(SAM_BROKER => 'MQED',SAM_TRANSACTIONS => SAM_MANUAL));
   
   if($conn->isConnected())
   {
      $msg = new SAMMessage('MY MESSAGE');

      $msg->header->SAM_REPLY_TO = 'MYGETQUEUE';
      $correlid = $conn->send('MYPUTQUEUE', $msg);

      if (!$correlid) {
        // The Send failed!
           echo "Send failed ($conn->errno) $conn->error";
      } else {
           $resp = $conn->receive('MYGETQUEUE', array(SAM_CORRELID => $correlid));
      }
   
      $conn->disconnect();
   }
   else
   {
      echo "Connection failed ($conn->errno) $conn->error";
   }



Thank you everyone in advance!


Last edited by eriben on Tue Nov 01, 2011 4:47 pm; edited 1 time in total
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Nov 01, 2011 1:06 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

You realize that in V7 XMS is part of the base product?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
bruce2359
PostPosted: Tue Nov 01, 2011 1:11 pm    Post subject: Re: Connecting to MQ using PHP Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

eriben wrote:

...but not MQOPEN

Are we to guess as to why you are not MQOPENing successfully? Did your app receive a ReasonCode? Did an FDC get generated? Any errors in the AMQERRnn.LOG files?
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
eriben
PostPosted: Tue Nov 01, 2011 1:13 pm    Post subject: Reply with quote

Newbie

Joined: 01 Nov 2011
Posts: 4

fjp_saper; I realize that it is part of the base product, but since our server is V6 I have two separate servers with each of the client versions just to rule that out. The V6 installation has IA94 installed.

bruce2359; as I wrote, the reason code was 2044 and no, there was nothing in the error log files and no FCP.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Tue Nov 01, 2011 1:47 pm    Post subject: Re: Connecting to MQ using PHP Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9469
Location: US: west coast, almost. Otherwise, enroute.

eriben wrote:


Code:
MQOPEN failed; CompCode:2 Reason:2044 Text:2044




Well, yes you did; but you hid it in code tags. I speed-read through these.

Common usage of code tags: use code tags to encompass what you or your developer wrote in a source language.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
eriben
PostPosted: Tue Nov 01, 2011 4:48 pm    Post subject: Re: Connecting to MQ using PHP Reply with quote

Newbie

Joined: 01 Nov 2011
Posts: 4

Quote:

Well, yes you did; but you hid it in code tags. I speed-read through these.

Common usage of code tags: use code tags to encompass what you or your developer wrote in a source language.


Ok, that's been fixed. Now, to the issue at hand... anyone that's successfully launched a solution like this?
Back to top
View user's profile Send private message
ramires
PostPosted: Tue Nov 01, 2011 6:01 pm    Post subject: Reply with quote

Knight

Joined: 24 Jun 2001
Posts: 523
Location: Portugal - Lisboa

Google for "mq php sample" you will find several examples
Back to top
View user's profile Send private message
eriben
PostPosted: Wed Nov 02, 2011 11:25 am    Post subject: Reply with quote

Newbie

Joined: 01 Nov 2011
Posts: 4

Thank you, that's what I did. By following the samples on for instance PHP.net et al, i get as far as MQCONN but fails on MQOPEN with 2044 without any FDC...
Back to top
View user's profile Send private message
ramires
PostPosted: Wed Nov 02, 2011 3:10 pm    Post subject: Reply with quote

Knight

Joined: 24 Jun 2001
Posts: 523
Location: Portugal - Lisboa

ok. The 2044 means MQRC_OD_ERROR The object descriptor structure is not valid. Open a pmr with IBM. From the samples found searching Google it seams others had success using php.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Installation/Configuration Support » Connecting to MQ using PHP
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.