JMSException:CWSIA0005E:JCA运行时无法创建连接

时间:2014-11-20 06:06:00

标签: java multithreading jms connection-pooling websphere-8

我在队列中发布消息(一次发送50条消息)时遇到两个异常。我在我的项目中使用ThreadLocal(也包括JMS发布类)。 我真的不知道为什么会这样。任何进一步行动的帮助表示赞赏。 提前谢谢。

Exception:javax.jms.JMSException: CWSIA0024E: The JCA runtime failed to create a session.          
    at com.ibm.ws.sib.api.jms.impl.JmsConnectionImpl.createJcaSession(JmsConnectionImpl.java:951)
    at com.ibm.ws.sib.api.jms.impl.JmsConnectionImpl.createSession(JmsConnectionImpl.java:340)
    at com.ibm.ws.sib.api.jms.impl.JmsQueueConnectionImpl.createQueueSession(JmsQueueConnectionImpl.java:115)
          ...
          ...
  Caused by: com.ibm.websphere.ce.j2c.ConnectionWaitTimeoutException: Connection not available, Timed out waiting for 180001
         at com.ibm.ejs.j2c.FreePool.createOrWaitForConnection(FreePool.java:1721)
         at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:3321)
         at com.ibm.ejs.j2c.PoolManager.reserve(PoolManager.java:2567)
         at com.ibm.ejs.j2c.ConnectionManager.allocateMCWrapper(ConnectionManager.java:1544)
         at com.ibm.ejs.j2c.ConnectionManager.allocateConnection(ConnectionManager.java:1027)
         at com.ibm.ws.sib.api.jmsra.impl.JmsJcaConnectionImpl.createSession(JmsJcaConnectionImpl.java:394)
         at com.ibm.ws.sib.api.jms.impl.JmsConnectionImpl.createJcaSession(JmsConnectionImpl.java:946)

Exception:javax.jms.JMSException: CWSIA0005E: The JCA runtime failed to create a connection
   ...

要发布的代码::

try {
        QueueConnectionFactory queueFactory = null;
        queueFactory = getQueueConnectionFactory(ConnectionFactoryJNDIName);
        // Create a QueueConnection
        queueConnection = queueFactory.createQueueConnection();
        try {
                // Create a QueueSession
                queueSession = queueConnection.createQueueSession(true,   Session.AUTO_ACKNOWLEDGE);
                Queue queue = getQueue(queueJNDIName);                  
                // Create the Publisher
                queueSender = queueSession.createSender(queue);
                // Create a message
                ObjectMessage objMsg = queueSession.createObjectMessage(object);
                // Publish the message
                queueSender.send(object);
                // Commit the session
                queueSession.commit();

            } catch (JMSException e) {
                throw e;
        } finally {
                try {
                    // Close the QueueSender
                    if (null != queueSender) {
                        queueSender.close();
                    }
                } catch (JMSException e) {
                        throw e;
                }
                try {
                    // Close the Queue Session
                    if (null != queueSession) {
                        queueSession.close();
                    }
                } catch (JMSException e) {
                    throw e;
                }
                try {
                    // Close the QueueConnection
                    if (null != queueConnection) {
                        queueConnection.close();
                    }
                } catch (JMSException e) {
                    throw e;
                }
    }  catch (Exception e) {
        throw e;
    }

配置:

  • 服务器:Websphere 8.5.5
  • 连接超时:300秒
  • 最大连接数:50
  • 未使用的超时:1800秒
  • 清除政策:EntirePool

1 个答案:

答案 0 :(得分:0)

导致问题的原因是ThreadLocal。在开始时设置ThreadLocal没有解决它。删除ThreadLocal后,问题已解决。