构建jar后无法向ibm mq发送消息 [英] Cannot sent message to ibm mq after building the jar
本文介绍了构建jar后无法向ibm mq发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1)当我在构思中运行该应用程序时,它可以正常工作.
1)When I run the app in idea it works.
public class Sender {
private MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
private MQQueueConnection connection = null;
private MQQueueSession session = null;
private Queue queue = null;
private MQQueueSender sender = null;
private TextMessage message = null;
public void send(String msg) throws JMSException {
cf.setHostName("host");
cf.setPort(port);
cf.setQueueManager("manager");
cf.setChannel("channel");
cf.setTransportType(WMQConstants.WMQ_CM_CLIENT);
connection = (MQQueueConnection) cf.createQueueConnection("user", "pswrd");
session = (MQQueueSession) connection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
queue = session.createQueue("queue");
sender = (MQQueueSender)session.createSender(queue);
message = session.createTextMessage(msg);
sender.send(message);
session.commit();
connection.close();
}
}
2)我添加了所有库
com.ibm.mqjms-7.5.0.4.jar
jms-1.1.jar
ibm.mq.jmqi-7.5.0.4.jar
com.ibm.mq.headers-7.5.0.4.jar
com.ibm.disthub2-7.5.0.4.jar
编辑
像这样到我的本地Maven存储库
to my local maven repo like this
mvn install:install-file -Dfile=jms-1.1.jar -DgroupId=com.ibm.jms -DartifactId=evkuzmin-jms -Dversion=1.0 -Dpackaging=jar
,然后将它们作为依赖项添加到项目中.
and then added them to the project as dependencies.
<dependency>
<groupId>com.ibm.jms</groupId>
<artifactId>evkuzmin-jms</artifactId>
<version>1.0</version>
</dependency>
3)我使用maven-assembly-plugin构建具有依赖项的jar.
3)I build using maven-assembly-plugin a jar with dependencies.
这是我得到的错误.
Exception in thread "main" com.ibm.msg.client.jms.DetailedJMSException: JMSWMQ0018: null
Caused by: com.ibm.mq.MQException: JMSCMQ0001: JMSCMQ0001, 2, MQCC_FAILED, 2195, MQRC_UNEXPECTED_ERROR
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2195;AMQ9204: Connection to host 'host(port)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2195],3=host(port),5=WMQThreadPool.enqueue]
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2195
Caused by: com.ibm.msg.client.commonservices.CSIException: JMSCS0002
包装后为什么会失败?
推荐答案
2)我添加了所有库
2)I added all libraries
那不是所有必需的MQ库.这些是必需的MQ JAR文件:
That's not all of the required MQ libraries. These are the required MQ JAR files:
- com.ibm.mq.commonservices.jar
- com.ibm.mq.headers.jar
- com.ibm.mq.jar
- com.ibm.mq.jmqi.jar
- com.ibm.mq.pcf.jar
- com.ibm.mqjms.jar
- connector.jar
- jms.jar
- jndi.jar
为什么不使用MQ V8 Client,然后仅使用名为com.ibm.mq.allclient.jar的MQ JAR文件
Why don't you use MQ V8 Client and then simply use the MQ JAR file called: com.ibm.mq.allclient.jar
这篇关于构建jar后无法向ibm mq发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文