Jakarta ee 为什么SIB连接关闭?(Websphere服务集成总线)

Jakarta ee 为什么SIB连接关闭?(Websphere服务集成总线),jakarta-ee,jms,websphere,Jakarta Ee,Jms,Websphere,我在WebSphere7.0.0.21上部署了一个消息驱动的BeanMDB,它在SIB服务集成总线队列上发送JMS消息 将创建JMS资源: @Resource(name = CONN_FACTORY, mappedName = CONN_FACTORY) private QueueConnectionFactory connFactory; @PostConstruct public void postConstruct() { queueConnection = connFactory.

我在WebSphere7.0.0.21上部署了一个消息驱动的BeanMDB,它在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

之外,我不确定是什么原因导致这里出现SIMPConnectionUnavailableException,但您在MDB中管理连接的方式无论如何都是不正确的。您应该将postConstruct和preDestroy方法中的代码移动到onMessage方法,而不要尝试重用同一连接。如果要确保MDB具有正确的事务行为,这一点尤其重要。请注意,由于连接工厂进行连接池,因此请求每个接收到的消息的连接不会导致开销。

根据Oracle的Java EE教程,在onMessage中管理资源的两种方法或我上面描述的方法都是正确的。我试着在onMessage中管理资源,它可以正常工作,但性能实际上要低得多!包括业务逻辑在内的1000条消息的耗时延长了约50%。