6 Replies Latest reply on Nov 23, 2010 12:37 AM by jaikiran

    Stateless Session Bean pool MaximumSize with strictMaximumSi

    ashley_betts70

      Hi all,
      I'm trying to restrict the number of active stateless session beans to 1 for a particular bean with no success. I've seen some of the comments/suggestions on other forums and have applied these but it still doesn't seem to recognise MaximumSize enforced with strictMaximumSize. The version of Jboss I'm currently using is 4.2.3.

      jboss.xml:

      <!DOCTYPE jboss PUBLIC
      "-//JBoss//DTD JBOSS 4.2//EN"
      "http://www.jboss.org/j2ee/dtd/jboss_4_2.dtd">

      <enterprise-beans>

      <ejb-name>coupledSeqResource</ejb-name>
      <jndi-name>coupledSeqResource</jndi-name>
      <configuration-name>SequentialRequires</configuration-name>

      </enterprise-beans>
      <container-configurations>
      <container-configuration extends="Standard Stateless SessionBean">
      <container-name>SequentialRequires</container-name>
      <container-pool-conf>
      1
      true
      </container-pool-conf>
      </container-configuration>
      </container-configurations>


      (for some reason the post seems to remove the tags MaximumSize and strictMaximumSize but they are there wrapping the values in container-pool-conf)

      When I check jmx-console it seems to show a maximum of 30 (and 2 as its current size after a couple of test executions):

      Name Type Access Value Description
      Name java.lang.String R StatelessDelegateWrapper MBean Attribute.
      StateString java.lang.String R Started MBean Attribute.
      CreateCount int R 2 MBean Attribute.
      State int R 3 MBean Attribute.
      InvokeStats org.jboss.ejb3.statistics.InvocationStatistics R MBean Attribute.
      CurrentSize int R 2 MBean Attribute.
      RemoveCount int R 0 MBean Attribute.
      MaxSize int R 30 MBean Attribute.
      AvailableCount int R 30 MBean Attribute.

      standardjboss.xml hasn't been modified from the standard release.

      Anyone have any suggestions to why this isn't working for me?

      Regards,

      Ashley

        • 1. Re: Stateless Session Bean pool MaximumSize with strictMaxim
          rmurugs

          in jboss.xml , add this and try out.


          <ejb-name>ejbName</ejb-name>
          <pool-config>
          <pool-class>org.jboss.ejb3.StrictMaxPool</pool-class>
          <pool-max-size>5</pool-max-size>
          <pool-timeout>60000</pool-timeout>
          </pool-config>

          • 2. Re: Stateless Session Bean pool MaximumSize with strictMaxim
            ashley_betts70

            Thanks for the response rmurugs.

            Unfortunately what you've suggested doesn't comply with the dtd: http://www.jboss.org/j2ee/dtd/jboss_4_2.dtd and won't build.

            Is there any other way I can enforce StrictMaxPool?

            • 3. Re: Stateless Session Bean pool MaximumSize with strictMaxim

              For EJB 3.0 you can edit the ejb3-interceptors-aop.xml file under /jboss_home/server/all/deploy directory. Edit the element for "Stateless Bean" with something like this
              @org.jboss.annotation.ejb.PoolClass (value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1, timeout=10000)


              I hope this helps.

              Thanks,

              • 4. Re: Stateless Session Bean pool MaximumSize with strictMaxim

                With StrictMaxPool class and maxSize 1 it blocks all the EJB calls and only allow one call. Is there a way to instance only one Object and not blocking? Like SingleTon bean. I am chasing a problem where too many EJB stateless bean are created. When I configure only one EJB call at a time which make system suffer for throughput.
                I want to create only one instance but the call shouldn't be blocked. Multiple threads should be able to access the ejb stateless pool. Let me know what are my options.

                • 5. Re: Stateless Session Bean pool MaximumSize with strictMaxim
                  aravindsk

                       i am not sure this is the right place for my question.

                  i am currently using 6.0 CR1 and implementing coding using ejb3.1

                   

                   

                  @Startup
                  @Singleton

                  @Startup

                  @Singleton

                   

                  public class StartupBean {

                  String item = "";

                   

                  @Resource

                  TimerService timerService;

                   

                  @EJB

                  SLSBean sBean;

                   

                   

                       @PostConstruct

                  public void init() {

                   

                  timerService.createTimer(1 * 60 * 1000, 1*60* 1000, item);

                   

                  }

                   

                  @Timeout

                  public void process(javax.ejb.Timer timer) {

                   

                  try {

                  sBean.process(timer);

                  } catch (Exception e) {

                   

                  e.printStackTrace();

                  }

                  }

                  }

                   

                   

                   

                  @Stateless

                  public class SLSBean {

                   

                  @Inject

                  private Logger logger;

                   

                   

                  @Asynchronous

                  public void process(javax.ejb.Timer timer) {}

                  }

                   

                   

                  my question is when it is always shows only one instace of SLSBean is created when i expected multiple slsb's

                   

                  config:

                  Available Count 1

                  Create Count 1

                  Current Count 1

                  Max Size 1 The maximum number of instances that are  allowed to be pooled

                   

                  ejb3-interceptors-aop.xml shows max size of  30.

                   

                        <annotation expr="class(*) AND !class(@org.jboss.ejb3.annotation.Pool)">
                            @org.jboss.ejb3.annotation.Pool (value="ThreadlocalPool", maxSize=30, timeout=10000)
                         </annotation>

                   

                  what is that i need to change so that multiple slsbs created and pooled.

                  • 6. Re: Stateless Session Bean pool MaximumSize with strictMaxim
                    jaikiran

                    Aravind, please continue this discussion in your other thread here http://community.jboss.org/message/572349#572349