Cannot sent message to ibm mq after building the jar

℡╲_俬逩灬. 提交于 2019-12-11 16:38:32

问题


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)I added all libraries

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

EDIT

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)I build using maven-assembly-plugin a jar with dependencies.

This is the error I get.

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

Why does it fail after packaging?


回答1:


2)I added all libraries

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

Why don't you use MQ V8 Client and then simply use the MQ JAR file called: com.ibm.mq.allclient.jar



来源:https://stackoverflow.com/questions/46159091/cannot-sent-message-to-ibm-mq-after-building-the-jar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!