我在队列中发布消息(一次发送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;
}
配置:
答案 0 :(得分:0)
导致问题的原因是ThreadLocal
。在开始时设置ThreadLocal
没有解决它。删除ThreadLocal
后,问题已解决。