4 Replies Latest reply on Nov 9, 2012 12:28 PM by kmarellapudi

    How can we use EJB2.1 entity caching in JBOSS7.1.1?

    ion_mayank

      How can we use EJB2.1 entity caching in JBOSS7.1.1?

      Till JBOSS6 this feature was available by configuring standardJBoss.xml and programmatic eviction was also possible through InvalidationManager API.

      XML file invoker configuration had the interceptor for caching the calls and to make Invalidation possible Invalidable needed to be set to true.

       

      Eviction API:

       


      Collection groups = (Collection) server.getAttribute(





      invalidationManagerName, "InvalidationGroups");

       

       




      Iterator groupIterator = groups.iterator();



      while (groupIterator.hasNext()) {




      InvalidationGroup invalidationGroup = (InvalidationGroup) groupIterator






      .next();




      String groupName = invalidationGroup.getGroupName();




      server.invoke(invalidationManagerName, "invalidateAll",






      new Object[] { groupName },






      new String[] { "java.lang.String" });

       

      How can I implement the same feature for EJB2.1 in JBOSS7.

       

      Mine is a legacy application which uses EJB2.1 extensively and caching is very important from performance point for the application.

        • 1. Re: How can we use EJB2.1 entity caching in JBOSS7.1.1?
          ion_mayank

          Here is the complete standardJBOSS.xml container configuration for Entity beans Cross Transactional cache:

              <container-configuration>

                <!--

                   | This is like standard IPT but with global (cross-transactional) row cache behind,

                   | i.e. no locking in EJB layer + global persistence data cache

                -->

                <container-name>cmp2.x jdbc2 pm</container-name>

                <call-logging>false</call-logging>

                <invoker-proxy-binding-name>entity-unified-invoker</invoker-proxy-binding-name>

                <sync-on-commit-only>false</sync-on-commit-only>

                <insert-after-ejb-post-create>true</insert-after-ejb-post-create>

                <call-ejb-store-on-clean>true</call-ejb-store-on-clean>

                <container-interceptors>

                   <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>

                   <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>

                   <interceptor>org.jboss.ejb.plugins.security.PreSecurityInterceptor</interceptor>

                   <interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>

                   <interceptor>org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>

                   <interceptor>org.jboss.ejb.plugins.EntityCreationInterceptor</interceptor>

                   <interceptor>org.jboss.ejb.plugins.EntityInstanceInterceptor</interceptor>

                   <interceptor>org.jboss.ejb.plugins.EntityReentranceInterceptor</interceptor>

                   <interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>

                   <interceptor>org.jboss.ejb.plugins.EntitySynchronizationInterceptor</interceptor>

                   <interceptor>org.jboss.ejb.plugins.cmp.jdbc2.RelationInterceptor</interceptor>

                </container-interceptors>

                <instance-pool>org.jboss.ejb.plugins.EntityInstancePool</instance-pool>

                <instance-cache>org.jboss.ejb.plugins.PerTxEntityInstanceCache</instance-cache>

                <persistence-manager>org.jboss.ejb.plugins.cmp.jdbc2.JDBCStoreManager2</persistence-manager>

                <locking-policy>org.jboss.ejb.plugins.lock.NoLock</locking-policy>

                <container-cache-conf>

                   <cache-policy-conf>

                      <min-capacity>500</min-capacity>

                      <max-capacity>10000</max-capacity>

                      <!-- uncomment to enable time-based eviction

                      <overager-period>300</overager-period>

                      <max-bean-age>600</max-bean-age> -->

                   </cache-policy-conf>

                   <cache-policy-conf-other>

                      <partitions>10</partitions>

                      <!-- uncomment to use JDBC java.sql.Statement.executeBatch()

                      <batch-commit-strategy/> -->

                      <invalidable/>

                   </cache-policy-conf-other>

                </container-cache-conf>

                <container-pool-conf>

                   <MaximumSize>100</MaximumSize>

                </container-pool-conf>

                <commit-option>C</commit-option> <!-- don't change, irrelevant, use container-cache-conf -->

              </container-configuration>

           

           

          If this is not implemented in JBOSS7, please suggest the alternative to achieve the same functionality for Entity Beans 2.1 using Infinispan Cache Manager.

          • 2. Re: How can we use EJB2.1 entity caching in JBOSS7.1.1?
            kmarellapudi

            We have similar requirements. We would also like to delay the persistence of entity beans until the end of the transaction. We were using container-configuration mechanisms in JBoss 4 to acheive this. But not sure if we have a similar mechanism in JBoss 7.1.1. Did you get an answer to this post?

            • 3. Re: How can we use EJB2.1 entity caching in JBOSS7.1.1?
              ion_mayank

              Hello Kamesh,

               

               

              As much to my knowledge, JBOSS7 does not support standard IPT with global (cross-transactional) row cache behind for EJB2.1 entities.

              If you want to migrate your EJB2.1 entities to JBOSS7, then you are bound to convert those EJB2.1 entities to EJB3.0 with a second level cache provider such as hibernate.

              EJB 3.0 entity manager automatically delays the persistence till end of transaction.

              • 4. Re: How can we use EJB2.1 entity caching in JBOSS7.1.1?
                kmarellapudi

                Thanks Mayank. We have over 1.5K EJB2.1 CMPs and I was able to port the whole app to JBoss7.1.1 and got it working mostly. If EJB2.1 caching is not supported we are going to lose big on the performance and also its essential we delay the actual persistence to the end of the transaction for both architectural reasons (we have some aspects of the app that assume that ejbStore is invoked only at the end of the transaction) and for performance reasons as well. Not sure how invasive this process of converting EJB2.1 to EJB3.0. Got to explore that option.

                 

                Thanks again for your quick reply.