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

时间:2012-05-24 17:11:05

标签: java-ee jms websphere

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

如果我大量增加Queue连接工厂的连接池大小,则错误很少发生但仍然存在。如果我降低池大小,则会经常发生错误。

如何关闭连接?如果我的连接池大小大于并发MDB的数量:s,如何关闭连接?

连接池有各种属性,但我找不到任何关于正在使用的关闭连接......我的代码肯定没有关闭任何连接(@PreDestroy除外)

1 个答案:

答案 0 :(得分:0)

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