Eclipse Paho和IBM Websphere MQ之间没有建立连接MQ

问题描述:

我是IBM MQ的新手用户。基本上我想建立客户端(Eclipse Paho)和IBM MQ队列管理器之间的连接。Eclipse Paho和IBM Websphere MQ之间没有建立连接MQ

我已执行以下步骤:

  • 我已经安装了IBM MQ v.9.0
  • 创建队列管理器
  • 发起者一个队列管理器与端口号服务(1414)
  • 创建服务器通道并将其与创建的队列管理器一起分配。

在客户端:

  • Downloadd Eclipse的泛美卫生组织,这是MQTT Java客户端。
  • 尝试用小程序连接启动的队列管理器。

Followinig是程序。

import java.util.logging.Logger; 

import org.eclipse.paho.client.mqttv3.MqttAsyncClient; 
import org.eclipse.paho.client.mqttv3.MqttClient; 
import org.eclipse.paho.client.mqttv3.MqttConnectOptions; 
import org.eclipse.paho.client.mqttv3.MqttException; 
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; 

public class MQMTTFactory { 

    private static Logger log = Logger.getLogger(MQMTTFactory.class.getName()); 
    private MQMTTFactory() { 

    } 

    static final String BROKER_URL = "tcp://<<Ipaddress>>:1234"; 
    static final String M2MIO_DOMAIN = "<Insert m2m.io domain here>"; 
    static final String M2MIO_STUFF = "things"; 
    static final String M2MIO_USERNAME = "Guest"; 
    static final String M2MIO_PASSWORD_MD5 = "<m2m.io password (MD5 sum of password)>"; 
    static MqttClient myClient = null; 

    public static MqttClient getMqttClient() { 
     MqttConnectOptions connOpt; 
     if (myClient == null) { 
      connOpt = new MqttConnectOptions(); 
      connOpt.setCleanSession(true); 
      connOpt.setKeepAliveInterval(3000); 
      connOpt.setUserName(M2MIO_USERNAME); 
      // connOpt.setPassword(M2MIO_PASSWORD_MD5.toCharArray()); 

      // Connect to Broker 
      try { 
       myClient = new MqttClient(BROKER_URL, 
         MqttAsyncClient.generateClientId(), new MemoryPersistence()); 
       myClient.connect(connOpt); 
      } catch (MqttException e) { 
       log.severe("Client connection to the MQTT Broker is failed"); 
       e.printStackTrace(); 
       System.exit(-1); 
      } 
     } 
     return myClient; 

    } 

} 

但上述程序未能建立与服务器的连接。 以下是运行上述程序时的错误。

Unable to connect to server (32103) - java.net.ConnectException: Connection refused: connect 

有没有人能告诉我什么可能是错的?或任何建议。

+1

做了qmgrs/QMGRNAME目录错误在你检查AMQERR01.LOG?你确定听众正在运行吗?你定义了什么渠道类型? – JoshMc

Eclipse Paho客户端仅适用于MQTT协议。这是一个基于主题的发布/订阅协议,不支持消息队列。

虽然IBM-MQ可以支持MQTT,但默认情况下未启用。

我建议你阅读下列2篇文章,更好地了解

  1. https://www.ibm.com/developerworks/community/blogs/aimsupport/entry/what_is_mqtt_and_how_does_it_work_with_websphere_mq?lang=en
  2. https://www.ibm.com/support/knowledgecenter/en/SS9D84_1.0.0/com.ibm.mm.tc.doc/tc00110_.htm