我在 WebSphere 7.0.0.21 上部署了一个消息驱动 Bean (MDB),它在 SIB(服务集成总线)队列上发送 JMS 消息。
创建 JMS 资源:
@Resource(name = CONN_FACTORY, mappedName = CONN_FACTORY)
private QueueConnectionFactory connFactory;
@PostConstruct
public void postConstruct() {
queueConnection = connFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(true, Session.AUTO_ACKNOWLEDGE);
responseQueueSender = queueSession.createSender(getResponseQueue());
}
并销毁:
@PreDestroy
public void preDestroy() {
responseQueueSender.close();
queueSession.close();
queueConnection.close();
}
像这样发送:
TextMessage responseMessage = queueSession.createTextMessage("message");
responseQueueSender.send(responseMessage, DeliveryMode.PERSISTENT, Message.DEFAULT_PRIORITY, expirationTime);
queueSession.commit();
我有大约 20 个 MDB 实例。当我向 MDB 生成大量传入消息时,就会出现问题。我收到以下错误:
CWSIA0053E: An exception was received during the call to the method JmsSessionImpl.getTransaction (#1): javax.resource.spi.IllegalStateException: CWSJR1121E: An internal error has occurred. During the call to the method getManagedConnection the exception javax.resource.spi.ResourceAllocationException: CWSJR1028E: An internal error has occurred. The exception com.ibm.ws.sib.processor.exceptions.SIMPConnectionUnavailableException: CWSIK0022E: The connection is closed to messaging engine seit3022Node01.server1-Payment and cannot be used. was received in method createManagedConnection. was thrown..
如果我将队列连接工厂的连接池大小增加很多,错误发生的几率会更低,但它仍然存在。如果我降低池大小,则会经常发生错误。
如何关闭连接?如果我的连接池大小大于并发 MDB:s 的数量,如何关闭连接?
连接池有各种属性,但我找不到任何关于关闭正在使用的连接...而且我的代码肯定不会关闭任何连接(除了@PreDestroy
)