3 Replies Latest reply on Oct 24, 2012 2:58 AM by jaikiran

    JBoss client api - how to listen to channel close events?

    sven.plath

      Hey,

       

      i have the following situation:

      • Server that exposes remote EJBs to clients.
      • Clients that have a steady connection to the Server.

       

      When the server fails, the client sees something like this:

       

      17:12:10,631  INFO ChannelAssociation:370 - Channel Channel ID e3fac859 (outbound) of Remoting connection 0026e9f9 to /10.150.240.137:4447 can no longer process messages
      17:12:10,641  INFO ChannelAssociation:370 - Channel Channel ID a3bf1681 (outbound) of Remoting connection 0026e9f9 to /10.150.240.137:4447 can no longer process messages
      17:12:10,651  INFO ChannelAssociation:370 - Channel Channel ID d6dd4eeb (outbound) of Remoting connection 0026e9f9 to null can no longer process messages
      17:12:10,651 ERROR RemoteNamingStoreV1:222 - Channel end notification received, closing channel Channel ID 96b8ffbc (outbound) of Remoting connection0026e9f9 to null
      17:12:10,651  INFO ChannelAssociation:370 - Channel Channel ID 8a2d8363 (outbound) of Remoting connection 0026e9f9 to null can no longer process messages
      

       

      But i did not find a way how to listen to these messages programatically. I obtain the InitialContext by using:

       

      final Properties env = new Properties();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
      env.put(Context.PROVIDER_URL, url);
      env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", user));
      env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", pwd));
      env.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
      env.put("jboss.naming.client.ejb.context", true);
      context = new InitialContext(env);
      

       

      Thanks in advance,

      Sven

        • 1. Re: JBoss client api - how to listen to channel close events?
          jaikiran

          Why do you want to listen to those notifications in your application?

          • 2. Re: JBoss client api - how to listen to channel close events?
            sven.plath

            The clients do repeating invocations of EJB methods during their lifetime. Therefore, the connection must be kept open. When the server goes down, the invocations to the clients fail with the stack trace shown below. I need to know when the connection goes down so i can prevent further invocations of EJB methods and go into some kind of "offline-mode".

             

            Sven

             

             

            Exception:

            Exception in thread "Thread-2" java.lang.IllegalStateException: No EJB receiver available for handling [appName:,modulename:***,distinctname:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@313170
                    at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:584)
                    at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:119)
                    at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181)
                    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:136)
                    at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:121)
                    at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104)
                    at $Proxy1.heartbeat(Unknown Source)
                    at foo.bar.Heartbeat.run(Heartbeat.java:40)
                    at java.lang.Thread.run(Thread.java:662)
            
            • 3. Re: JBoss client api - how to listen to channel close events?
              jaikiran

              If you have to go into offline mode then you have two options:

               

              1) Use JBoss Remoting and EJB client APIs to create and manage the connections on your own and you can then receive such notifications from JBoss Remoting

              OR

              2) Rely on the IllegalStateException with a message id of EJBCLIENT000024 which suggests that there was no receiver available for handling this invocation (there can be many reasons why the receiver isn't available, one being the server was down, but in any case the invocation can't proceed).