Search code examples
c++ibm-mqxms

Unable to connect to Websphere MQ Manager using XMS


This code reproduces the issue:

#include <iostream>
#include <xms.hpp>

int main()
{
    try
    {
        xms::ConnectionFactory factory;

        factory.setIntProperty(XMSC_CONNECTION_TYPE,      XMSC_CT_WMQ);
        factory.setIntProperty(XMSC_WMQ_CONNECTION_MODE,  XMSC_WMQ_CM_CLIENT);
        factory.setStringProperty(XMSC_WMQ_QUEUE_MANAGER, "my.queue.manager");
        factory.setStringProperty(XMSC_WMQ_HOST_NAME,     "my.dev.mq");
        factory.setStringProperty(XMSC_WMQ_CHANNEL,       "my.channel");
        factory.setIntProperty(XMSC_WMQ_PORT,              1414);

         std::cout << "Is Factory Null? => " << factory.isNull() << std::endl;
         xms::Connection conn = factory.createConnection(); //THIS THROWS EXCEPTION
         std::cout << "Is Factory Null? => " << factory.isNull() << std::endl;
    }
    catch(xms::Exception const & e)
    {
         e.dump(std::cout);
    }
}

It throws exception, dumping the following message:

Is Factory Null? => 0
Exception:
ErrorData =
ErrorCode = 26 (XMS_E_CONNECT_FAILED)
JMS Type  = 1 (XMS_X_GENERAL_EXCEPTION)
Linked Exception:
ErrorData = libmqic_r.so
ErrorCode = 0 (XMS_E_NONE)
JMS Type  = 1 (XMS_X_GENERAL_EXCEPTION)

Any idea what is wrong with the code?

Note that devpmmq is just an alias to the actual IP address (host). If I put any random/nonsense value for it, I get the same error, which is bad because the API should have given a better error message such as "host not found" or something alone that line. Is there any way to enable more verbose diagnostics?


Solution

  • XMS C/C++ internally loads WebSphere MQ client libraries. The problem here is that XMS is unable to find WebSphere MQ client library libmqm_r.so.

    What is puzzling me is that the code has set XMSC_WMQ_CONNECTION_MODE as XMSC_WMQ_CM_CLIENT but XMS is attempting to load libmqm_r.so. It should have attempted to load libmqic_r.so.

    Have you installed WebSphere MQ client? Also what is the version of XMSClients can be downloaded from here.