WMQ MQJCA1018 错误

   如下代码,如果连接工厂factory是自己new出来的,那么 这段代码执行没问题;但是一旦放置到JBOSS容器下,连接工厂通过JNDI方式从容器获取,就会报错:
   MQJCA1018: Only one session per connection is allowed 。
ConnectionFactory  factory = getFactory();
Connection connection = null;
Session session1= null;
Session session2= null;
connection = factory.createConnection();
connection.start();
session1 = connection.createSession(true, Session.SESSION_TRANSACTED);
//connection1 = factory.createConnection();
session2 = connection.createSession(true, Session.SESSION_TRANSACTED);


查询IBM MQ information Center ,得到信息如下:

WMQ JMS Exception Messages

ERROR CODE(错误码)
   MQJCA1018
Explanation(解释)
   The application attempted to create more than one JMS session on the same JMS connection. This exception occurs only if the application is running in a managed environment.
User Action(解决方案)
   Modify the application so that it creates only one JMS session on a JMS connection.

看起来,从容器获取的jms 连接必须遵守 一个connection,一个session的原则;为什么这么设计呢,且先记下,以后再想原因

你可能感兴趣的:(jmsconnection)