0
votes

Hi I am trying to IBM MQ using JMS. I am getting below error

JMSWMQ0018: Failed to connect to queue manager 'SM2T' with connection mode 'Client' and host name 'null'

Here is my code:

public void putMessageToqueue() throws JMSException {
        JMSContext context = null;
        Destination destination = null;
        JMSProducer producer = null;
        JMSConsumer consumer = null;
        
        JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
        JmsConnectionFactory cf = ff.createConnectionFactory();

        // Set the properties
        cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, queueHost);
        cf.setIntProperty(WMQConstants.WMQ_PORT, port);
        cf.setStringProperty(WMQConstants.WMQ_CHANNEL, queueChannel);
        cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
        cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, queueManager);
        cf.setStringProperty(WMQConstants.WMQ_APPLICATIONNAME, "JmsPutGet (JMS)");
        cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, true);
        cf.setStringProperty(WMQConstants.USERID, queueUser);
        cf.setStringProperty(WMQConstants.PASSWORD, queueUser);
        cf.setStringProperty(WMQConstants.WMQ_SSL_CIPHER_SUITE, "TLS_RSA_WITH_AES_128_CBC_SHA256");
        cf.setStringProperty("javax.net.ssl.trustStore", trustStore);
        cf.setStringProperty("javax.net.ssl.keyStore", trustStore);
        cf.setStringProperty("javax.net.ssl.keyStorePassword", "");
        cf.setStringProperty("com.ibm.mq.cfg.useIBMCipherMappings", "false");
        
        
        context = cf.createContext();
        destination = context.createQueue("queue:///" + queueName);

        long uniqueNumber = System.currentTimeMillis() % 1000;
        TextMessage message = context.createTextMessage("Your lucky number today is " + uniqueNumber);
        producer = context.createProducer();
        producer.send(destination, message);
        System.out.println("Sent message:\n" + message);

                    context.close();

        //recordSuccess();
        
    }

could you please let me know issue ASAP

Here the main issue is Hostname is coming as nullprasanth kotagiri
Are you initializing variable queueHost?Shashi