Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: V3
    • Fix Version/s: 3.1
    • Component/s: ejb_container
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      13,004

      Description

      As in Issue 11964 we have configured message driven beans with:

      <bean-pool>
      <steady-pool-size>1</steady-pool-size>
      <resize-quantity>1</resize-quantity>
      <max-pool-size>1</max-pool-size>
      <pool-idle-timeout-in-seconds>0</pool-idle-timeout-in-seconds>
      </bean-pool>

      and expected to see only one mdb ever created for this pool since
      pool-idle-timeout-in-seconds with 0 requires the container to leave created
      instances for ever and the has to be just 1 instance.
      Instead, as soon as a mesage arrives 2 MDB's are created of which one is
      discarded after the message is processed.

        Activity

        Hide
        marina vatkina added a comment -

        -> Cheng

        Show
        marina vatkina added a comment - -> Cheng
        Hide
        Cheng Fang added a comment -

        Working on it now. Will add a flag in glassfish-ejb-jar.xml to enable this
        singleton behavior. The singleton bean instance is per jvm, and will apply to
        single-instance server, not a cluster. In case of system exception, the bean
        instance will be discarded, and a new singleton instance will be created.

        Show
        Cheng Fang added a comment - Working on it now. Will add a flag in glassfish-ejb-jar.xml to enable this singleton behavior. The singleton bean instance is per jvm, and will apply to single-instance server, not a cluster. In case of system exception, the bean instance will be discarded, and a new singleton instance will be created.
        Hide
        Cheng Fang added a comment -

        Fix checked in.

        Added a property option, singleton-bean-pool, in glassfish-ejb-jar.xml (or
        sun-ejb-jar.xml if you are still using the old name). For example,

        <sun-ejb-jar>
        <enterprise-beans>
        <ejb>
        <ejb-name>MDB1</ejb-name>
        <jndi-name>jms/ejb_mdb_singleton_InQueue</jndi-name>
        <resource-ref>
        <res-ref-name>jms/MyQueueConnectionFactory</res-ref-name>
        <jndi-name>jms/ejb_mdb_singleton_QCF</jndi-name>
        <default-resource-principal>
        <name>guest</name>
        <password>guest</password>
        </default-resource-principal>
        </resource-ref>
        <bean-pool>
        <steady-pool-size>1</steady-pool-size>
        <resize-quantity>1</resize-quantity>
        <max-pool-size>1</max-pool-size>
        <pool-idle-timeout-in-seconds>3</pool-idle-timeout-in-seconds>
        </bean-pool>
        </ejb>
        <ejb>
        <ejb-name>FooBean</ejb-name>
        <bean-pool>
        <steady-pool-size>1</steady-pool-size>
        <resize-quantity>1</resize-quantity>
        <max-pool-size>1</max-pool-size>
        <pool-idle-timeout-in-seconds>600</pool-idle-timeout-in-seconds>
        </bean-pool>
        </ejb>
        <message-destination>
        <message-destination-name>MsgBeanInQueue</message-destination-name>
        <jndi-name>jms/ejb_mdb_singleton_InQueue</jndi-name>
        </message-destination>
        <message-destination>
        <message-destination-name>MsgBeanOutQueue</message-destination-name>
        <jndi-name>jms/ejb_mdb_singleton_OutQueue</jndi-name>
        </message-destination>
        <property>
        <name>singleton-bean-pool</name>
        <value>true</value>
        </property>
        </enterprise-beans>
        </sun-ejb-jar>

        If steady-pool-size is 1, max-pool-size is 1, and
        <enterprise-beans><property>singleton-bean-pool is true, then it's considered
        single-instance pool.

        Note that the <property> is under <enterprise-beans> element and may affect all
        ejb's under it.

        This fix is intended primary for mdb singleton, but it also apply to stateless
        session beans. For stateless, a better option is to use the standard, portable
        @javax.ejb.Singleton (introduced in EJB 3.1).

        Show
        Cheng Fang added a comment - Fix checked in. Added a property option, singleton-bean-pool, in glassfish-ejb-jar.xml (or sun-ejb-jar.xml if you are still using the old name). For example, <sun-ejb-jar> <enterprise-beans> <ejb> <ejb-name>MDB1</ejb-name> <jndi-name>jms/ejb_mdb_singleton_InQueue</jndi-name> <resource-ref> <res-ref-name>jms/MyQueueConnectionFactory</res-ref-name> <jndi-name>jms/ejb_mdb_singleton_QCF</jndi-name> <default-resource-principal> <name>guest</name> <password>guest</password> </default-resource-principal> </resource-ref> <bean-pool> <steady-pool-size>1</steady-pool-size> <resize-quantity>1</resize-quantity> <max-pool-size>1</max-pool-size> <pool-idle-timeout-in-seconds>3</pool-idle-timeout-in-seconds> </bean-pool> </ejb> <ejb> <ejb-name>FooBean</ejb-name> <bean-pool> <steady-pool-size>1</steady-pool-size> <resize-quantity>1</resize-quantity> <max-pool-size>1</max-pool-size> <pool-idle-timeout-in-seconds>600</pool-idle-timeout-in-seconds> </bean-pool> </ejb> <message-destination> <message-destination-name>MsgBeanInQueue</message-destination-name> <jndi-name>jms/ejb_mdb_singleton_InQueue</jndi-name> </message-destination> <message-destination> <message-destination-name>MsgBeanOutQueue</message-destination-name> <jndi-name>jms/ejb_mdb_singleton_OutQueue</jndi-name> </message-destination> <property> <name>singleton-bean-pool</name> <value>true</value> </property> </enterprise-beans> </sun-ejb-jar> If steady-pool-size is 1, max-pool-size is 1, and <enterprise-beans><property>singleton-bean-pool is true, then it's considered single-instance pool. Note that the <property> is under <enterprise-beans> element and may affect all ejb's under it. This fix is intended primary for mdb singleton, but it also apply to stateless session beans. For stateless, a better option is to use the standard, portable @javax.ejb.Singleton (introduced in EJB 3.1).
        Hide
        jthoennes added a comment -

        This is great news.

        Many thanks to Marina and Cheng taking care of this!

        I guess this will also improve performance since process many messages using
        singleton MDBs.

        Do you consider making this part of the standard JEE6 singleton API for a later
        release, ie 3.2? I guess the new property is just some sort of workaround for
        the moment.

        My idea would to allow custom thread-pools to be configured for MDBs. If the
        size of the thread-pool is 1, then this is singleton behaviour. This is the way
        JBoss used to implement this for years.

        Cheers, Jörg

        Show
        jthoennes added a comment - This is great news. Many thanks to Marina and Cheng taking care of this! I guess this will also improve performance since process many messages using singleton MDBs. Do you consider making this part of the standard JEE6 singleton API for a later release, ie 3.2? I guess the new property is just some sort of workaround for the moment. My idea would to allow custom thread-pools to be configured for MDBs. If the size of the thread-pool is 1, then this is singleton behaviour. This is the way JBoss used to implement this for years. Cheers, Jörg
        Hide
        marina vatkina added a comment -

        Jörg, any requests for the spec changes need to be sent to the EJB expert group
        (e.g. via http://wiki.jcp.org/boards/index.php?b=jsr-318-public page - you need
        to log in to leave a comment).

        Best,
        -marina

        Show
        marina vatkina added a comment - Jörg, any requests for the spec changes need to be sent to the EJB expert group (e.g. via http://wiki.jcp.org/boards/index.php?b=jsr-318-public page - you need to log in to leave a comment). Best, -marina

          People

          • Assignee:
            Cheng Fang
            Reporter:
            petraleomue
          • Votes:
            2 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: