3 Replies Latest reply on Feb 27, 2006 2:42 AM by Sriram Padmanabhan

    Optimistic Locking policy in jboss

    Sriram Padmanabhan Newbie

      Hi
      I have a question regarding locking policy in jboss. I am using an oracle database. Now what I am doing is, I am updating a set of records from oracle using normal JDBC Connection (using a datasource of course), from an MDB.The update operation takes some time since there are a number of records. Meanwhile i m trying to update the same set of reocords from another thread,(which can be a java program or a normal sql plus window) but this updation wont happen unless the transaction in the MDB completes. So for this(since i know the default locking policy is Pessimistic), i made the locking policy as Optimistic, and I assume that the above scenario should work.But this does not work. Can any one explain why this is not working. I have pasted my jboss.xml below

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN"
      "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">



      <enterprise-beans>


      <ejb-name>FilterBuilderService</ejb-name>
      <local-jndi-name>mercury-catalog-admin-1.0/ejb/com.ketera.catalog.service.FilterBuilderService</local-jndi-name>


      <message-driven>
      <ejb-name>CacheBuilderMDB</ejb-name>
      <destination-jndi-name>queue/CatalogQueue</destination-jndi-name>
      </message-driven>

      <container-configurations>

      <container-configuration>
      <locking-policy>org.jboss.ejb.plugins.lock.JDBCOptimisticLock</locking-policy>
      </container-configuration>

      </container-configurations>


      </enterprise-beans>

        • 1. Re: Optimistic Locking policy in jboss
          Prashan Wewelwala Newbie

          Hi,

          First of all, I think your jboss.xml is not properly written. It should be like this :

          <jboss>
           <enterprise-beans>
           <entity>
           <ejb-name>CacheBuilderMDB</ejb-name>
           <local-jndi-name>mercury-catalog-admin-1.0/ejb/com.ketera.catalog.service.FilterBuilderService</local-jndi-name>
           <configuration-name>CMP 2.x Optimistic Locking</configuration-name>
           </entity>
          
           <message-driven>
           <ejb-name>CacheBuilderMDB</ejb-name>
           <destination-jndi-name>queue/CatalogQueue</destination-jndi-name>
           </message-driven>
          
           </enterprise-beans>
          
           <container-configurations>
           <container-configuration extends="Standard CMP 2.x EntityBean">
           <container-name>CMP 2.x Optimistic Locking</container-name>
           <locking-policy>org.jboss.ejb.plugins.lock.JDBCOptimisticLock</locking-policy>
           </container-configuration>
           </container-configurations>
          </jboss>
          


          Remember, if you change the container configuration and want to apply the new configuration to beans, you have to specify the new configuration name under each bean's <configuration-name> tag, otherwise, the default configuration will be used.

          Hope this helps.

          Regards,

          Indy.

          • 2. Re: Optimistic Locking policy in jboss
            Sriram Padmanabhan Newbie

            Hi
            I tried what you have mentioned in the reply. But still it is not working.
            Please have a look at my jboss.xml. I have purposefully added a space for session tag. So do consider that as a mistake. Other than than can you tell me is there something else where i am going wrong.


            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN"
            "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">


            <enterprise-beans>
            < session>
            <ejb-name>FilterBuilderService</ejb-name>
            <local-jndi-name>mercury-catalog-admin-1.0/ejb/com.ketera.catalog.service.FilterBuilderService</local-jndi-name>
            </ session>
            <message-driven>
            <ejb-name>CacheBuilderMDB</ejb-name>
            <destination-jndi-name>queue/CatalogQueue</destination-jndi-name>
            <container-name>CMP 2.x Optimistic Locking</container-name>
            </message-driven>
            <container-configurations>
            <container-configuration extends="Standard CMP 2.x EntityBean">
            <container-name>CMP 2.x Optimistic Locking</container-name>
            <locking-policy>org.jboss.ejb.plugins.lock.JDBCOptimisticLock</locking-policy>
            </container-configuration>
            </container-configurations>
            </enterprise-beans>


            • 3. Re: Optimistic Locking policy in jboss
              Sriram Padmanabhan Newbie

              Hi,
              To add to my above comments i also looked in to the standardjboss.xml where, i saw different container configurations. There i noticed that the <locking-policy> is only applied on Entity Beans ( Container managed as well as Bean Managed). Is it possible to apply a <locking-policy> for Session Beans as well as Message Driven Beans.

              Regards
              Sriram