如何使用HornetQ处理JMS会话超时



任何人都可以解释如何处理JMS会话超时。在我的应用程序中,我正在使用Hornetq,它在一段时间后工作正常,错误会出现(JMS会话超时),请帮助我。公共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();
    }
}

感谢

尝试在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。

最新更新