Raghava Vaddi
Raghava Vaddi

Reputation: 31

How to handle JMS-Session timeout using HornetQ?

can any one explain how to handle JMS-Session timeout.In my application am using Hornetq its working fine after sometime the error will getting( JMS-Session timeout) please help me. public 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();

    }
}

Thanks

Upvotes: 1

Views: 2409

Answers (1)

Andrey Lyubimov
Andrey Lyubimov

Reputation: 247

Try to configure connection factory in HornetQ configuration file like this.

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

To handle JMS timeout try to work with JMSException.

Upvotes: 1

Related Questions