MQ

MQ

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  setHost

    Posted 5 hours ago

    Hey folks,

    we recently came across a situation where an application was failing to connect to queue manager because the hostname was invalid, this was previously working with the active node not being the last one in the list. The application had a list of mq hosts in the connection parameters and only one of them is active at anytime (RDQM HADR).
    They were using "setHostName" and "setPort" under MQQueueConnectionFactory class, they were defining both. 

    PS: I know that they should ahve used connectionname list instead of "setHostName" and "setPort" , but the app team is curious how the connection worked all this time until we saw a failure, here's a successa nd faiklure scenario

    WORKS (when qmgr runs on any node)
    primary0(12345),primary1(12345),primary2(12345),secondary0(12345),secondary1(12345),secondary2
    NOTE1: the last host enrty has the port skipped intentionally apparantly. (This is old code and no one knows why)

    FAILS (fails when qmgr runs active on the last node, but works for everything else )
    primary0(12345),primary1(12345),primary2(12345),secondary0(12345),secondary1(12345),secondary2(12345)

    NOTE2: The error below appends another port number to the last host (which was active in the scenario that failed)

    Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2538;AMQ9204: Connection to host 'secondary2(12345)(12345)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2538;AMQ9205: The host name supplied is not valid. [3=secondary2(12345),4=TCP]],3=secondary2(12345)(12345),4=,5=RemoteTCPConnection.parseConnectionName]

    Just curious how the hostname string is being interpreted in general when using "setHostName" and "setPort",we have advised the app team to to use "setConnectionNameList" instead of "setHostname"


    CODE snippet: 

    private MQQueueConnectionFactory mqQueueConnectionFactoryBill() {
    MQQueueConnectionFactory mqQueueConnectionFactory = new MQQueueConnectionFactory();

    try {
      mqQueueConnectionFactory.setQueueManager(queueManager);
      mqQueueConnectionFactory.setChannel(channel);

      mqQueueConnectionFactory.setPort(port);
      mqQueueConnectionFactory.setHostName(host);

    //   mqQueueConnectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
    //    mqQueueConnectionFactory.setStringProperty(WMQConstants.WMQ_CONNECTION_NAME_LIST, host);

      // mqQueueConnectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
    //   // mqQueueConnectionFactory.setCCSID(WMQConstants.CCSID_UTF8);
    //   // set service account - with value = user: tovmqnp
      if (!sslCipherSuite.isEmpty()) {
       mqQueueConnectionFactory.setSSLCipherSuite(sslCipherSuite);
      }

      mqQueueConnectionFactory.setTransportType(CommonConstants.WMQ_CM_CLIENT);
      mqQueueConnectionFactory.setSSLSocketFactory(getSSLConfigContext().getSocketFactory());
      mqQueueConnectionFactory.setSSLFipsRequired(false);
      System.out.println(auth);
      mqQueueConnectionFactory.setBooleanProperty(CommonConstants.USER_AUTHENTICATION_MQCSP, auth);

      logger.info("mqQueueConnectionFactory initialized..!!! ==> {}", mqQueueConnectionFactory);
      logger.info("mqQueueConnectionFactory  connection ..!!! ==> {}",
        mqQueueConnectionFactory.createConnection());
      logger.info("mqQueueConnectionFactory ..!!! ==> {}", mqQueueConnectionFactory.getClientReconnectOptions());
    } catch (Exception e) {
      e.printStackTrace();
    }
    return mqQueueConnectionFactory;
    }



    ------------------------------
    Abhilash Gadila
    ------------------------------