1 2 Previous Next 16 Replies Latest reply on Jan 14, 2004 8:25 AM by mkprim

    JMS onException not working

    mkprim

      Hi, I'm using a JMS TemporaryQueue based on a connection beteween a swing client and a server, and I need to detect when there's a network problem and either the client or the server gets disconnected.
      For example, when I shut my JBoss 3.2.2 server down, the client detects the exception via the onException method (it impements ExceptionListener) and tries to recconect.
      However, this does not happen in the server when a client disconnects. When I kill the client, no execption is triggered, so the server never knows this client has been killed.

      Here's the Server code:

      //The part where I set the listener
      qc = serviceLocator.getQueueConnectionFactory("UIL2ConnectionFactory").createQueueConnection(username, password);
      qc.setExceptionListener(this);
      qc.start();


      //The onException Part
      public void onException(JMSException exception) {
      try {
      //qc.stop();
      qc.close();

      //publico el evento de desconexion para los listeners q les interese.
      System.out.println("Deleting connection (onException)");
      DisconnectedEvent discEvt = new DisconnectedEvent(this);
      sendDisconnected(discEvt);
      } catch (JMSException e) {
      System.out.println("ERROR DE CONEXION: " + e);
      e.printStackTrace();
      }
      }

      I never get to this onException method.
      Anybody has experienced this problem? Anybody know what could be?
      Thanks a lot.

        • 1. Re: JMS onException not working

          How can onException be triggered if the client is dead?

          If you mean you killed the network, an exception will be triggered when it
          tries to ping the server (once every minute in the default configuration).

          There is a read timeout parameter so that the server can detect the client
          vanishing.

          Regards,
          Adrian

          • 2. Re: JMS onException not working
            mkprim

            Thanks for your reply. Now I understan how it works.

            "There is a read timeout parameter so that the server can detect the client
            vanishing. "

            I have another question, then:
            I kill my client but when the 60 seconds of detection complete, the server does not detect the client. Even if I leave it for some minutes...
            So I reduced the PingPeriod to 200 and the ReadTimeout to 800. Whis this numbers it does work, but (I don't know why) I leave the client connected doing nothing, and it also detects the client disconnection, when the client is connected.
            Do I need to implement my own ping message every xxxx miliseconds and send it as a JMS message?
            Thanks,
            Marcelo


            • 3. Re: JMS onException not working
              mkprim

              any help¿?

              • 4. Re: JMS onException not working

                Why would it work with a read timeout of 800 millis-seconds but not 70 seconds?
                You've got something strange going on.

                Regards,
                Adrian

                • 5. Re: JMS onException not working
                  mkprim

                  I didn't change anything in the client. Just changed the server configuration.
                  Maybe I've got to change the client ping and read timeout?
                  In the case, where (what files or properties)?

                  • 6. Re: JMS onException not working
                    mkprim

                    I forgot to mention that I notice the disconnection using an onExceptionMessage on a class that implements the ExceptionListener interface, and is suscribed to the connection.
                    Thanks

                    • 7. Re: JMS onException not working

                      I don't understand the question.

                      The configuration is on the server. The client pings otherwise the server timesout.

                      Regards,
                      Adrian

                      • 8. Re: JMS onException not working
                        mkprim

                        Understood.
                        Does it make sense that the server never respects the specified read timeout?
                        Do you have any single idea about what might be?
                        Thanks

                        • 9. Re: JMS onException not working
                          mkprim

                          Please can anybody help me?
                          This is really urgent and I've been trying to solve it for three days.
                          Thanks.

                          • 10. Re: JMS onException not working

                             

                            "adrian@jboss.org" wrote:
                            First, how do you know the server still thinks the client is connected?
                            Have you looked at debug/trace messages to see whether the server
                            is quietly detecting the failure?

                            If the read timeout is not working, it is a problem with your network,
                            tcp/ip stack or virtual machine. i.e. a bug
                            Didn't you mention it works with a small timeout but not with a large timeout?

                            Reards,
                            Adrian


                            • 11. Re: JMS onException not working
                              mkprim

                               

                              "mkprim" wrote:
                              >First, how do you know the server still thinks the client is connected?
                              >Have you looked at debug/trace messages to see whether the server
                              >is quietly detecting the failure?
                              I debugged the server using the JBossIDE in eclipse, looking the onException method. Its not called at all. Should I debug something else?

                              >If the read timeout is not working, it is a problem with your network,
                              >tcp/ip stack or virtual machine. i.e. a bug
                              >Didn't you mention it works with a small timeout but not with a large timeout?

                              It didn't work fine. I think the timeout was so small, that a connected client couldn't make it to send a ping, so the server "disconnected" it. Funny, with 600 ms it doesn't work either, that being fast enough.

                              Any other suggestions? Just don't know what to do.


                              • 12. Re: JMS onException not working
                                mkprim

                                I've discovered that my JBoss at startup logs this message:

                                11:49:22,610 INFO [SnmpAgentService] Starting heartbeat controller ...
                                11:49:22,610 WARN [Heartbeat] Heartbeat disabled

                                Does this have anuthing to do with the client detection?
                                How can I fix this to enable the Heartbeat Service?

                                • 13. Re: JMS onException not working

                                   

                                  "adrian@jboss.org" wrote:
                                  You have completely confused me. I don't think you have read what I'm telling you.

                                  onException is invoked when the client loses the connection to the server.
                                  It is likely to be invoked when the client tries to ping the server and it fails.

                                  The detection by the server of the client going away will not invoke onException on the
                                  client.
                                  How can it, it has lost the connection to the client.

                                  One of your queries was about the client crashing. It cannot invoke onException
                                  after a crash. The program is no more.

                                  Regards,
                                  Adrian


                                  • 14. Re: JMS onException not working
                                    mkprim

                                     

                                    "mkprim" wrote:
                                    Ok.
                                    First, I've read your posts.
                                    Second, I have two onException methods:
                                    1) In the client, to detect server crashes.
                                    2) In the server, to detect client crashes or disconnection.

                                    I Don't expect the server to invoke a client's onException (as you said the client has crashed!)
                                    I Expect the server detecting a client crash in its own (server) onException.
                                    Here are the steps I follow on the server.
                                    1) Receive a TemporaryQueueConnection from the client
                                    2) Get a reference to the connection and set an exceptionListener that is on the server.
                                    3) Kill the client once it is connected
                                    4) Expect the server to invoke its own onException.

                                    Thats it.
                                    I hope this is not bothering you.
                                    Thanks,
                                    Marcelo


                                    1 2 Previous Next