ARTICLE AD BOX
We are(multiple JAVA applications) connecting to IBM MQ using the JMS / JNDI approach in a WebSphere Application Server environment.
Each request follows the below high-level flow:
Create a JNDI InitialContext using
com.ibm.websphere.naming.WsnInitialContextFactory
Look up the JMS ConnectionFactory via JNDI
(for example: jms/ABCD)
Look up the request queue and reply queue using JNDI
Create a JMS Connection from the ConnectionFactory
Create a non-transacted JMS Session with AUTO_ACKNOWLEDGE
Start the connection
Create a MessageProducer
Construct and send the MQ request message (CIH format)
Close all JMS and JNDI resources in the finally block
similarly, we created the session connection for consumer.
The JNDI and JMS connection creation logic is as follows:
context = new InitialContext(environment); ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("jms/ABCD"); Destination requestQueue = (Destination) context.lookup(requestQueueName); Destination replyQueue = (Destination) context.lookup(replyToQueueName); connection = connectionFactory.createConnection(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); connection.start(); producer = session.createProducer(requestQueue); producer.send(message);Occasionally, when multiple applications invoke this JMS service concurrently, the application server throws the following exception during connection creation:
javax.jms.JMSException: Failed to create connection at com.ibm.ejs.jms.JMSCMUtils.mapToJMSException(JMSCMUtils.java:140) at com.ibm.ejs.jms.JMSConnectionFactoryHandle.createConnection(JMSConnectionFactoryHandle.java:277) at com.hdb.jms.JMSServiceSender.doCicsRequestReplySend(JMSServiceSender.java:84) at com.hdb.jms.JMSService.CicsRequestReply(JMSService.java:30)When this issue occurs:
The failure happens at connectionFactory.createConnection()
We are unable to identify which calling application is causing the issue
The problem is intermittent and occurs under concurrent load
All JMS and JNDI resources are explicitly closed in the finally block to avoid resource leaks:
finally { if (producer != null) { producer.close(); } if (session != null) { session.close(); } if (context != null) { context.close(); } if (connection != null) { connection.close(); } }