4 Replies Latest reply on Nov 28, 2001 10:00 AM by jimboj

    Controling the number of stateless session bean instances

    conora

      Hi there,

      I'm wondering if anyone has managed to control the
      absolutle number of stateless session beans of a particular type.

      I'm hoping to use a stateless session bean to hold a
      socket connection. I want to limit the number of socket connections made and 'funnel' all the requests
      through those few session beans holding a socket connection.

      Seem to me like this might be a common problem.

      Any thoughts??

      Conor

        • 1. Re: Controling the number of stateless session bean instance
          callum

          Hi there,

          I would think you would be able to add another container configuration for this particular type of stateless bean to the conf/tomcat/standardjboss.xml file and then refer to that configuration in your jboss.xml for that particular bean. Alternatively you can add the configuration definition into your jboss.xml file instead of the standard xml.

          Either way it should work (though haven't tried it)

          Callum

          • 2. Re: Controling the number of stateless session bean instance
            jimboj

            Hey,

            I would probably suggest that you use a socket factory and pool and use the bean to retrieve a socket from the pool. I'm not so sure its a good idea to have a socket associated entirely with a bean instance. This way you can configure the pool and factory to limit the number of sockets and just use the bean as a facade or consumer of the sockets

            J

            • 3. Re: Controling the number of stateless session bean instance
              conora

              Thanks for your thoughs....

              I've had a few over the weekend myself....

              1) Add an interceptor which effectively blocks until
              a socket becomes free
              2) Write a connector ? -

              I like the socket factory and pool idea ....

              Is there anywhere where I might find some more details
              about this approach?

              Conor

              • 4. Re: Controling the number of stateless session bean instance
                jimboj

                Hi Conor,

                Not sure if its in the J2EE catalog, or something similar at http://developer.java.sun.com/developer/restricted/patterns/J2EEPatternsAtAGlance.html but you could start with a singleton/facade that maintains a pool of connections and provides possibly synchronised access to obtain and return them. The facade/pool could be configured or initialized statically with the appropriate number of connections, or it could start with none and grow to a maximum when connections are required. There will be plenty of code around to demonstrate the use of pooling of resources

                J