11 Replies Latest reply on Jan 13, 2009 11:59 PM by Ron Sigal

    Socket keep alive with client EJB

    amar slimane Newbie

      Hello,

      We are using a Swing client standalone which invokes EJB methods.
      After each call, the socket is released.

      For security reasons, we have to maintain the connection (keep alive)
      and not release it after each call.

      Is it possible to do this.

        • 1. Re: Socket keep alive with client EJB
          Ron Sigal Master

          Which version of the Application Server are you using?

          Version 2.4.0 of Remoting has a solution to your problem based on JIRA issue JBREM-877 "New Socket Connection is being Created for Every Client Request to the Server". Remoting 2.4.0.CR1 (the latest 2.4.0 release) should be compatible with JBoss AS 5.0.0.Beta4.

          This feature does not exist in version 2.2.x, which ships with the 4.2 versions of the Application Server. One fact to note is that multiple copies of org.jboss.remoting.Client (which is used by EJB3 clients) connected to the same server share the same underlying invoker and connection pool. If you keep one EJB3 alive, that should be enough to keep a shared connection pool in existence.

          • 2. Re: Socket keep alive with client EJB
            amar slimane Newbie

            We are using JBoss AS 5.0.0.Beta4 but i don't know the version of Remoting which ships with it.

            How can i get the version of Remoting in JBoss AS 5.0.0.Beta4 ?

            Thanks.

            • 3. Re: Socket keep alive with client EJB
              Ron Sigal Master

              One way is to go to .../server/default/lib and execute

              java -jar jboss-remoting.jar


              which will print the version.

              By the way, version 2.4.0.CR2 is now available from http://repository.jboss.com/jboss/remoting/.

              • 4. Re: Socket keep alive with client EJB
                amar slimane Newbie

                The version of JBossRemoting which ships with JBoss AS 5.0.0.Beta4 is :
                JBossRemoting Version 2.2.2.SP4 (Bluto)

                I have downloaded JBossRemoting 2.4.0.CR2 then placed jboss-remoting.jar in JBoss AS 5.0.0.Beta4 and it works fine.

                When we set the parameter "invokerDestructionDelay" to a positive value (milliseconds), the same socket connection is reused for all llient requests to the Server.

                Thanks you very much.

                PS : Do you know when JBossRemoting 2.4.0.CR2 will be used in JBoss AS ?

                • 5. Re: Socket keep alive with client EJB
                  Ron Sigal Master

                   


                  Do you know when JBossRemoting 2.4.0.CR2 will be used in JBoss AS ?


                  The plan is for Remoting 2.4.0.GA to ship with AS 5.0.0.CR1. I'm not sure of the current schedule, though.

                  • 6. Re: Socket keep alive with client EJB
                    amar slimane Newbie

                    Using JBoss Remoting 2.4.0 with JBossAS 5.0.0Beta4, the parameter 'invokerDestructionDelay' is taken into account and the socket connection is reused for all client requests.

                    But with JBossAS 5.0.0GA and JBoss Remoting 2.5.0SP2 embedded, the socket connection is closed, apparently by the server, after 60 seconds of inactivity.
                    The value of 'invokerDestructionDelay' is 28800000.

                    • 7. Re: Socket keep alive with client EJB
                      Ron Sigal Master

                       

                      "slimamar" wrote:

                      Using JBoss Remoting 2.4.0 with JBossAS 5.0.0Beta4, the parameter 'invokerDestructionDelay' is taken into account and the socket connection is reused for all client requests.

                      But with JBossAS 5.0.0GA and JBoss Remoting 2.5.0SP2 embedded, the socket connection is closed, apparently by the server, after 60 seconds of inactivity.
                      The value of 'invokerDestructionDelay' is 28800000.


                      These two behaviors aren't really contradictory. There are two things going on. On the client side, setting "invokerDestructionDelay" allows the client invoker, with its connection pool, to stay alive longer than it would otherwise. Suppose you set "invokerDestructionDelay" to 10000 and you create, connect, invoke upon, and disconnect a new org.jboss.remoting.Client every five seconds. Since the client invoker stays alive for ten seconds, it will still be there when you create the next Client, and the existing connection will get reused.

                      On the server side, the connection is managed by a worker thread which, when it is not executing an invocation, is waiting in a socket read(). When it times out, which it does in 60 seconds by default, the socket is closed and the worker thread is returned to the thread pool.

                      If you make an invocation every five seconds, then the socket on the server side will never time out, and the same connection will be used every time. On the other hand, if you make an invocation every two minutes, then, even though you use the same client invoker with the same connection pool each time, you won't be able to reuse the old connection, which gets closed after sixty seconds, so each invocation will use a new connection.

                      So the frequency of the invocations and the server side timeout determine if you get to reuse connections.

                      Make sense?



                      • 8. Re: Socket keep alive with client EJB
                        amar slimane Newbie

                        Yes, i understand the two behaviors.
                        Sorry, i think my question is not cleary and needs some precisions.

                        With JBossAS 5.0.0Beta4, we have set the value of the parameter 'timeout' , for the server side, in the file 'JBOSS_HOME/server/<your_configuration>/deploy/ejb3-connectors-service.xml'.
                        And it's woks fine.

                        But, with JBossAS 5.0.0GA, we don't manage to specify a value of this parameter and we don't know where to do this. Apparently, this is the file BOSS_HOME/server/<your_configuration>/deploy/ejb3-connectors-jboss-beans.xml.

                        In the documentation, there is this :
                        "You can configure JBoss Remoting through the JBoss Messaging service configuration file JBOSS_HOME/server/<your_configuration>/deploy/messaging/remoting-service.xml."
                        But this file doesn't exist and does reference to 'messaging'.

                        The problem is how to set this parameter on the server side.

                        Thanks in advance.

                        • 9. Re: Socket keep alive with client EJB
                          Ron Sigal Master

                          Ah, yes, you're quite right about ejb3-connectors-service.xml, which introduces two new things:

                          1. the new Remoting configuration method, using the org.jboss.remoting.ServerConfiguration object, and

                          2. the ServiceBindingManager.

                          The ServerConfiguration doesn't play a big role in ejb3-connectors-service.xml, though a more extensive example can be found in .../deploy/remoting-jboss-beans.xml, which replaces the Remoting configuration that used to be in conf/jboss-service.xml. More information about ServerConfiguration can be found in Section 5.1.1.3. "Declarative configuration: POJOs" of the Remoting Guide (http://www.jboss.org/jbossremoting/docs/guide/2.5/html/index.html).

                          The updated ServiceBindingManager, which makes it easy to configure ports for the various services, is discussed in the wiki at http://www.jboss.org/community/docs/DOC-9038.

                          In any case, despite the changes, the InvokerLocator is given explicitly, just as it used to be in .../deploy/ejb3.deployer/jboss-service.xml:

                           <property name="invokerLocator">
                          
                           <value-factory bean="ServiceBindingManager"
                           method="getStringBinding">
                           <parameter>
                           jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3
                           </parameter>
                           <parameter>
                           <null />
                           </parameter>
                           <parameter>socket://${jboss.bind.address}:${port}</parameter>
                           <parameter>
                           <null />
                           </parameter>
                           <parameter>3873</parameter>
                           </value-factory>
                          
                           </property>
                          


                          Just change

                           <parameter>socket://${jboss.bind.address}:${port}</parameter>
                          


                          to

                           <parameter>socket://${jboss.bind.address}:${port}/?timeout=12345</parameter>
                          


                          "slimamar" wrote:

                          In the documentation, there is this :
                          "You can configure JBoss Remoting through the JBoss Messaging service configuration file JBOSS_HOME/server/<your_configuration>/deploy/messaging/remoting-service.xml."
                          But this file doesn't exist and does reference to 'messaging'.


                          That sounds like something that should be fixed. Where did you see it?

                          Thanks.

                          • 10. Re: Socket keep alive with client EJB
                            amar slimane Newbie

                            Ok, it work's fine.
                            I'm going to see the details about this new configuration.
                            Thanks once again.


                            That sounds like something that should be fixed. Where did you see it?

                            http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Administration_And_Configuration_Guide/5/html/ch11s02.html

                            • 11. Re: Socket keep alive with client EJB
                              Ron Sigal Master

                              Thanks for that reference to the Administration_And_Configuration_Guide. Yes, that should be fixed.