为什么 SIB 连接关闭?(Websphere Service Integration Bus)



我在 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

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

最新更新