3 Replies Latest reply on Sep 6, 2004 2:43 PM by Pedro Salazar

    RW/RO cache invalidation

    Dave Head-Rapson Newbie


      Hi,

      I'm having trouble implementing the RO/RW pattern for EJBs in the same JVM, as described in the Clustering documentation.

      I have 2 EJBs, one deployed read-write (VendorEJB) and one deployed read-only (VendorEJBReadOnly). What i require is that on updating the RW EJB, the cache for the other RO EJB should be invalidated.

      Both ejbs deply correctly, and the InvalidationGroup MBean is displayed in the JMX console, but currently when I update the RW EJB, the RO EJB cache doesn't invalidate.

      Can anyone spot an obvious error in the descriptors ? Does anyone know if the value in the <transaction-attribute> could affect this ? I currently have the 'Required' for the RW EJBs and NotSupported for the RO EJBs.

      I'm using the brand new 3.2.2 production version & I've included the code below. Any help anyone can offer would be greatly appreciated.

      My ejb-jar.xml includes
      <ejb-jar>

      <ejb-name>VendorEJB</ejb-name>
      <local-home>com.communix.catalog.ejb.vendor.VendorLocalHome</local-home>
      com.communix.catalog.ejb.vendor.VendorLocal
      <ejb-class>com.communix.catalog.ejb.vendor.VendorEJB</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>VendorSchema</abstract-schema-name>
      <cmp-field>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>visible</field-name>
      </cmp-field>
      <primkey-field>id</primkey-field>


      <ejb-name>VendorEJBReadOnly</ejb-name>
      <local-home>com.communix.catalog.ejb.vendor.VendorLocalHome</local-home>
      com.communix.catalog.ejb.vendor.VendorLocal
      <ejb-class>com.communix.catalog.ejb.vendor.VendorEJB</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>VendorSchemaReadOnly</abstract-schema-name>
      <cmp-field>
      <field-name>id</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>visible</field-name>
      </cmp-field>
      <primkey-field>id</primkey-field>

      </ejb-jar>

      My jboss.xml reads:


      <enterprise-beans>

      <ejb-name>VendorEJB</ejb-name>
      <local-jndi-name>ejb/catalog/Vendor</local-jndi-name>
      <read-only>false</read-only>
      <configuration-name>VendorEJB Container Configuration</configuration-name>
      <cache-invalidation>True</cache-invalidation>
      <cache-invalidation-config> <invalidation-group-name>VendorEJBGroup</invalidation-group-name>

      </cache-invalidation-config>


      <ejb-name>VendorEJBReadOnly</ejb-name>
      <local-jndi-name>ejb/catalog/VendorReadOnly</local-jndi-name>
      <read-only>true</read-only>
      <configuration-name>VendorEJBReadOnly Container Configuration</configuration-name>
      <cache-invalidation>True</cache-invalidation>
      <cache-invalidation-config>
      <invalidation-group-name>VendorEJBGroup</invalidation-group-name>

      </cache-invalidation-config>

      </enterprise-beans>
      <container-configurations>
      <container-configuration extends="Standard CMP 2.x EntityBean">
      <container-name>VendorEJB Container Configuration</container-name>
      <commit-option>C</commit-option>
      </container-configuration>
      <container-configuration extends="Standard CMP 2.x EntityBean">
      <container-name>VendorEJBReadOnly Container Configuration</container-name>
      <commit-option>A</commit-option>
      </container-configuration>
      </container-configurations>



      My jbosscmp-jdbc.xml reads:


      <jbosscmp-jdbc>

      <ejb-name>VendorEJB</ejb-name>
      java:/datasource-localpetstorePool
      <datasource-mapping>Oracle9i</datasource-mapping>
      <table-name>VENDOR</table-name>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>VENDORID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>visible</field-name>
      <column-name>VISIBLE</column-name>
      </cmp-field>


      <ejb-name>VendorEJBReadOnly</ejb-name>
      java:/datasource-localpetstorePool
      <datasource-mapping>Oracle9i</datasource-mapping>
      <table-name>VENDOR</table-name>
      <cmp-field>
      <field-name>id</field-name>
      <column-name>VENDORID</column-name>
      </cmp-field>
      <cmp-field>
      <field-name>visible</field-name>
      <column-name>VISIBLE</column-name>
      </cmp-field>

      </jbosscmp-jdbc>

      Thanks in advance
      Dave

        • 1. Re: RW/RO cache invalidation
          nraghuram Newbie

          in your container configuration you are extending "Standard CMP 2.x Entity Bean" whereas you should be extending "Standard CMP 2.x Entity Bean with cache invalidation" . check the standardjboss.xml. you will find this configuration
          raghu

          • 2. Re: RW/RO cache invalidation
            Dave Head-Rapson Newbie

            Doh!! Thanks for your help. It worked straight away!

            Dave

            • 3. Re: RW/RO cache invalidation
              Pedro Salazar Newbie

              Dave,

              Can you share with me a working EAR sample with me? Just to see the integral descriptors, and the sources files?

              I'm doing the same thing but the invalidation isn't working.
              I already tried many transactions configurations (supported,required, ...). I already confirmed that my RW ejb is calling the load()+store() every time. Only the RO calls the load() the first time.

              I think I really need a sample test. It appears that your descriptors are the same as I have (the basic stuff), but there must be a mistake somewhere.

              If need, I can send you my EAR plus my test case to show you.

              I'm using jboss 3.2.5.

              regards,
              Pedro Salazar