此代码重现了该问题:
#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);
}
}
抛出异常,转储以下消息:
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)
知道代码有什么问题吗?
请注意,devpmmq
只是实际IP地址(主机)的别名。如果我为其添加任何随机/无意义值,我会得到相同的错误,这是错误的,因为API应该给出更好的错误消息,例如“找不到主机”或单独的那条线。有没有办法启用更多详细诊断?
答案 0 :(得分:1)
XMS C / C ++在内部加载WebSphere MQ客户端库。这里的问题是XMS无法找到WebSphere MQ客户端库libmqm_r.so
。
让我感到困惑的是,代码已将XMSC_WMQ_CONNECTION_MODE
设置为XMSC_WMQ_CM_CLIENT
,但XMS正在尝试加载libmqm_r.so
。它应该尝试加载libmqic_r.so
。
您是否安装了WebSphere MQ客户端?还有哪些版本的XMSClients可以从here下载。