【问题标题】:How to handle JMS-Session timeout using HornetQ?如何使用 HornetQ 处理 JMS-Session 超时?
【发布时间】:2012-07-25 02:12:50
【问题描述】:

任何人都可以解释如何处理 JMS-Session 超时。在我的应用程序中,我正在使用 Hornetq,它在一段时间后会出现错误(JMS-Session 超时)后工作正常,请帮助我。 公共 HornetQProducer() {

    try {
        ic = getInitialContext();

        cf = (ConnectionFactory) ic.lookup("/ConnectionFactory");
        queue = new HornetQQueue("ExampleQueue");
        connection = cf.createConnection();
        logger.info("Connection object of HornetQ <<<>>>>>>>" + connection);
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        messageProducer = session.createProducer(queue);
        connection.start();
        logger.info("Message Producer HornetQ....." + messageProducer);
    } catch (NamingException e) {
        e.printStackTrace();
    } catch (JMSException e) {
        e.printStackTrace();

    }
}

谢谢

【问题讨论】:

  • 什么时候发生异常?请发布堆栈跟踪。你在使用持久会话吗?接收或发送消息时会发生这种情况吗?
  • 当异常发生超时时,我正在使用侦听器类。
  • 发布堆栈跟踪。没有它很难帮助你。
  • 代码没问题。它显示了您如何连接到 JMS 提供程序。你可以做到的事实。但在那之后发生了一些错误。 Stacktrace 可以帮助了解正在发生的事情。

标签: java tcp jms hornetq


【解决方案1】:

尝试像这样在 HornetQ 配置文件中配置连接工厂。

<connection-factory name="NettyConnectionFactory">
  <xa>false</xa>
  <connectors>
     <connector-ref connector-name="netty"/>
  </connectors>
  <entries>
     <entry name="/ConnectionFactory"/>
  </entries>
  <retry-interval>1000</retry-interval>
  <retry-interval-multiplier>1.0</retry-interval-multiplier>
  <reconnect-attempts>1</reconnect-attempts>
</connection-factory>

要处理 JMS 超时,请尝试使用 JMSException。

【讨论】:

    猜你喜欢
    • 2012-10-29
    • 1970-01-01
    • 1970-01-01
    • 2011-06-02
    • 2011-12-25
    • 2012-05-08
    • 2013-11-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多