我正在尝试通过独立服务器连接到ibm mq队列。 (我使用的是7.0.3 ibmmq jar)
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, "dcc");
cf.setIntProperty(WMQConstants.WMQ_PORT, 14321);
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, "dfds");
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, "dw");
cf.setStringProperty(WMQConstants.USERID, "ww");
cf.setStringProperty(WMQConstants.PASSWORD, "vw");
我在连接工厂中设置了所有这些属性。 Conenction成功,但我无法打开队列。得到以下错误。
**MQJE001: Completion Code '2', Reason '6114'.**
FAILED: Queueconnection
com.ibm.msg.client.jms.DetailedJMSException: JMSWMQ2008: Failed to open MQ queue 'US.0732931.NGEN.MANIFEST.LOADS'.
JMS attempted to perform an MQOPEN, but WebSphere MQ reported an error.
Use the linked exception to determine the cause of this error. Check that the specified queue and queue manager are defined correctly.
at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:585)
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:221)
答案 0 :(得分:0)
你真的没有提供足够的信息。
以下是示例代码:
private void putMessage()
{
JmsConnectionFactory cf = null;
Connection connection = null;
Session session = null;
Destination reqQ = null;
MessageProducer producer = null;
try
{
// Create a connection factory
JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
cf = ff.createConnectionFactory();
cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, "MY_QMGR_NAME");
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, "MY_TEST_CHL");
cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, "some_remote_server");
cf.setIntProperty(WMQConstants.WMQ_PORT, 1414);
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
cf.setStringProperty(WMQConstants.USERID, "my_uid");
cf.setStringProperty(WMQConstants.PASSWORD, "my_pwd");
// Create JMS objects
connection = cf.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
/**
* Create destination to send requests
* - MQA1 is the queue manager name
* - TEST.Q1 is the queue name
*/
reqQ = session.createQueue("queue://MQA1/TEST.Q1");
// Create producer
producer = session.createProducer(reqQ);
// Create a message
Message myMsg = session.createTextMessage("This is a test message.");
// Send it
producer.send(myMsg);
}
catch(Exception ex)
{
System.err.println(ex.getLocalizedMessage());
}
finally
{
try
{
session.close();
}
catch (Exception ex)
{
System.err.println("session.close() : " + ex.getLocalizedMessage());
}
try
{
connection.close();
}
catch (Exception ex)
{
System.err.println("connection.close() : " + ex.getLocalizedMessage());
}
}
}