1 Reply Latest reply on Jun 11, 2013 5:47 AM by Andy Taylor

    How to refresh the connection of consumer when HQ is deleted & created on Server

    sameer shukla Newbie

      Hi,

       

      I have a jboss-ejb client which is normal java process & it sends the request to Jboss Server deployed ejb service over RMI & receives the response on the HornetQ.

       

      HornetQ is in Jboss & client uses following code & properties for creating consumer & listener for the HornetQueue of remote Jboss server  :

       

       

      final Properties env = new Properties();

       

      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

       

      env.put(Context.PROVIDER_URL, "remote://10.11.12.13:4447");

       

      env.put(Context.SECURITY_PRINCIPAL, "guest");

       

      env.put(Context.SECURITY_CREDENTIALS, "guestp");

       

      context = InitialContext(env);

       

      final String connectionFactoryString = "jms/RemoteConnectionFactory";

       

      connectionFactory = (ConnectionFactory) context.lookup(connectionFactoryString);

       

      Destination destination = (Destination) context.lookup("HQueue");

       

      // Create the JMS connection, session, producer, and consumer

      connection = connectionFactory.createConnection("guest", "guestp");

       

      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

       

      consumer = session.createConsumer(destination);

       

      consumer.setMessageListener(new MessageListener(){

       

      @Override

      public void onMessage(Message arg0) {

            System.out.println("Message received");

        }

       

      });

       

      connection.start();

       

       

      The issue is that whenever the remote Jboss server is un-gracefully shutdown & enabled again then my client looses the connection with HornetQueue deployed on that Jboss.

       

      The ejb client is able to send the request to the ejb deployed on the Jboss without performing the JNDI lookup again but my client doesnt receive the responses from the queue.

       

      Every time I have to restart my client process which creates a new consumer & listener for the HornetQueue then it start receiving the responses.

       

      Is there any mechanism in HornetQueue or JMS which tell my client that remote HornetQueue connection has gone down & came up again, so that I can create a listener for these events & refresh my lookup towards the remote HornetQueue without restarting my client process.

       

      Something like https://community.jboss.org/message/757534?_sscc=t  & https://issues.jboss.org/browse/HORNETQ-1023

       

      I am using EAP 6.0.1 & corresponding jboss-client jar.

       

      Please advice how & what mechanism I can use for this scenario.

       

       

      Thanks in advance.