5 Replies Latest reply on Sep 3, 2011 4:56 AM by atgrohn

    How to recover from connection failures at client side

    atgrohn

      Hi folks,

       

      I am using JBOSS 6 Final and developing client side Java class which

      would take care of exchaning messages between the client and the server. Server has input and

      output queues for the client. The server is running with default HornetQ settings.

       

      Java class periodically polls internal taskList and sends any messages found at taskList to the server.

      It also provides public method for receiving message from the server.

       

      I am having problems in getting the receive direction (consumer) to work again aften there has

      been a internet connection failure or after jboss restart.

       

      Sometimes receive direction queue has no consumers and sometimes more than one consumer, naturally causing

      the message reception at client to fail.

       

      My first approach was to adjust the Connecion-TTL and ClientFailureCheckPeriod and let the HornetQ layer

      do the recovery, I still ended up in situation with no consumers.

       

      My current solution combines also the Application Level Failover....I know it's something one shouldn't do, it works better,

      but it's not perfect.

       

      What is the correct way to handle connection failures at the client?

       

      Simplified source attached.

       

      Cheers, Antti

        • 1. Re: How to recover from connection failures at client side
          atgrohn

          Hi,

           

          Just wanted to clarify more:

           

          I am using this class as part application which carries real time information to time table displays at bus stops over UMTS / GSM network.

           

          If I remove the exceptionListener and the special settings of connectionFactory from my code, it takes (I think) about 90 seconds until the client notices possible connectivity issues at the network connection. If the network connectivy comes back before the 90s limit, the consumer is already gone,

          it never receives new messages from the server.

           

          Can I somehow tell to the underlying session that I want my consumer back instead of recreating it?

           

          The producer seems to be alive and kicking after network failure....That makes me wonder.

           

          Antti

          • 2. Re: How to recover from connection failures at client side
            atgrohn

            Hello,

             

            Any comments welcomed.

             

            If I remove the exeptionListener and reCreateComsumer method and simply initialize the connectionFactory like this

             

            cf.setConnectionTTL(new Long(30000));
            cf.setReconnectAttempts(-1);
            cf.setRetryInterval(new Long(30000));
            cf.setRetryIntervalMultiplier(new Double(1.0));
            cf.setMaxRetryInterval(new Long(30000));
            cf.setClientFailureCheckPeriod(new Long(30000));

             

            Am I doing wrong if I expect that the client will try reconnect forever under any circumstances and after connection has been re-established both the consumer and producer will work?

             

            I am having difficulties in finding any info about reusing the connection, session, consumer and producer over single connection.

             

            I ealier ran the consumer and producer on separate threads and simply closed and reopened the connections on any exception, which is somewhat stupid approach, I think...

             

            Antti

            • 3. Re: How to recover from connection failures at client side
              clebert.suconic

              Did you look at the confirmation window size for reattachments?

              • 4. Re: How to recover from connection failures at client side
                atgrohn

                Thanks,

                 

                I Did not realize this, althouhg red the chapter 34.1 several times:

                 

                               Setting this parameter to -1 disables any buffering and prevents any re-attachment from occurring, forcing reconnect instead.

                               The default value for this parameter is -1.

                 

                What would be reasonable value for the window size?

                 

                What happens if failure is longer than the ConnectionTTL / ClientFailureCheckPeriod, Should I then do something manually or just wait until everything works again.

                 

                Antti