0

I am novice user to IBM MQ. Basically I want to establish the connection between Client(Eclipse Paho) and IBM MQ Queue Manager.

I have performed the following steps:

  • I have installed the IBM MQ v.9.0
  • Created a Queue Manager
  • Started a Queue Manager as a service with the port number(1414)
  • Create a Server channel and assigns this with created Queue Manager.

At Client side:

  • Downloadd Eclipse Paho, which is MQTT Java client.
  • try to small program to connect with started Queue Manager.

Followinig is the program.

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;

    }

}

But the above program is failed to establish the connection with the server. the following is the error while running the above program.

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

Could any body tell me what might be the wrong? or Any suggestions.

JoshMc
  • 10,239
  • 2
  • 19
  • 38
M.S.Naidu
  • 2,239
  • 5
  • 32
  • 56
  • 1
    Did your check the AMQERR01.LOG under the qmgrs/QMGRNAME directory for errors? Are you sure the listener is running? What channel type did you define? – JoshMc Aug 05 '17 at 18:41

1 Answers1

0

The Eclipse Paho client only works with the MQTT Protocol. This is a topic based pub/sub protocol and does not support Message Queues.

While IBM-MQ can support MQTT it is not enabled by default.

I suggest you read the following 2 articles to get a better understanding

  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
hardillb
  • 54,545
  • 11
  • 67
  • 105