【问题标题】:Why is SIB connection closed? (Websphere Service Integration Bus)为什么 SIB 连接关闭? (Websphere 服务集成总线)
【发布时间】:2012-05-31 07:33:07
【问题描述】:

我在 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 除外)

【问题讨论】:

    标签: jakarta-ee jms websphere


    【解决方案1】:

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

    【讨论】:

    • 根据 Oracle 的 Java EE 教程 (docs.oracle.com/javaee/6/tutorial/doc/bncgl.html),两种管理资源的方式(在 onMessage() 或我上面描述的方式)都是正确的。我尝试在 onMessage() 中管理资源,它可以正常工作,但性能实际上要低得多! (包括业务逻辑在内的 1000 条消息的耗时增加了大约 50%。)
    猜你喜欢
    • 2020-06-19
    • 1970-01-01
    • 1970-01-01
    • 2020-10-06
    • 1970-01-01
    • 1970-01-01
    • 2011-05-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多