1 Reply Latest reply on Jul 3, 2006 6:30 AM by manik

    Row Level Locking without Transactions

    appterasandy

      Essentially, we are looking for transaction support without JTA. Thus far, all the JTA implementations we have found (JOTM, SimpleJTA, etc) requires some database or file structure to log transaction logs. We're trying to set up a clustered environment where there are no single points of failure. Thus making most JTA implementations problematic.

      Is it possible to have limited row level locking and releasing without JTA implementation? We want to create a very simple and limited support for transactions like this:

      {start transaction or lock a row in table}
      val = get(key);
      val++;
      put(key, val);
      {release transaction or a row in table}


      I am using TreeMap's _lock() and releaseAllLock() function, and it seems to be doing absolutely nothing.


      treeMap._lock(fqn, 0, true);
       if(null == treeMap.getObject(fqn)){
       treeMap.putObject(fqn, new Integer(0));
       }
       else{
       //Integer intVal = (Integer) rMap.get(key);
       Integer intVal = (Integer) treeMap.getObject(fqn);
      
       int iVal = intVal.intValue();
       System.out.println("Got: " + intVal + " Put: " + (iVal+1));
       iVal++;
       treeMap.putObject(fqn, new Integer(iVal));
      
       }
       treeMap.releaseAllLocks(fqn);


      I have two machines running this code, and I'll get situations where get() returns the same number multiple times. Essentially it looks like the put isn't getting replicated across. Any other ideas on how to do row level locking perhaps?


        • 1. Re: Row Level Locking without Transactions
          manik

          Essentially, calling methods starting with _ are internal and will not trigger aspects such as replication, etc.

          In future releases (from 2.0.0) these methods will be internalised and not be accessible from the client API.

          I normally don't recommend the DummyTransactionManager that comes with JBoss, but if you are looking for a very simplistic TM to effectively 'batch up' requests, this may be a solution.

          Keep in mind that the DummyTransactionManager is not supported or recommended for production use though.