Search code examples
ibm-mq

Excess time taken to connect to a queue manager


I’ve inherited some connection factory JMS code, in some shared connection logic, and the time taken to create a queue manager connection is very long. Does anyone know what might be causing this?

// Create a connection factory
      JmsFactoryFactory ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER);
      JmsConnectionFactory cf = ff.createConnectionFactory();

      // Set the properties
      cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, HOST);
      cf.setIntProperty(WMQConstants.WMQ_PORT, PORT);
      cf.setStringProperty(WMQConstants.WMQ_CHANNEL, CHANNEL);
      cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
      cf.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, QMGR);
      cf.setStringProperty(WMQConstants.WMQ_APPLICATIONNAME, "Conversation Sharing Test");
      cf.setBooleanProperty(WMQConstants.USER_AUTHENTICATION_MQCSP, true);
      cf.setStringProperty(WMQConstants.USERID, APP_USER);
      cf.setStringProperty(WMQConstants.PASSWORD, APP_PASSWORD);
      cf.setIntProperty(WMQConstants.WMQ_SHARE_CONV_ALLOWED, WMQConstants.WMQ_SHARE_CONV_ALLOWED_NO);

Solution

  • I think this is because this line here:

    cf.setIntProperty(WMQConstants.WMQ_SHARE_CONV_ALLOWED, WMQConstants.WMQ_SHARE_CONV_ALLOWED_NO);

    is turning off conversation sharing, which means that every JMSContext, or Connection and Session, that the application creates uses its own channel instance to the queue manager. Creating a new instance each time adds some overhead, which means that it takes longer to create the JMS objects. Because of this, I'd recommend removing that line to allow the JMSContexts, Connections and Sessions to share channel instances where applicable.

    There's some more information about this here: https://developer.ibm.com/articles/awb-sharing-mq-conversations-over-channel-instances/

    Hope this helps! Paul