1 Reply Latest reply on May 21, 2008 3:59 PM by sankul123

    Local SSL process [method - CMT used] atomic operations issu

    sankul123

      Hi ALL,

      I have a following process, to be done by (Local)SSB[Stateless Session Bean]-
      <atomic operations in a method in SSL>
      1. Persist [update] some values in database.
      2. Some file operations , write some data to file.
      </atomic operations>

      I want both operations to be atomic. My Local SSL EJB is a CMT and its method 'transaction' attribute is marked for new transaction.
      Code:

      void myAtomicProcess(String a, String b)throws MyException{
      
      //1. update db...
      
      //2. update file ...
      
      }




      If there is any exception while committing [at the end of method] , I want to rollback my changes done to file i,e restore the file as it was.

      Please help me to achieve this.

        • 1. Re: Local SSL process [method - CMT used] atomic operations
          sankul123

          This is how I have implemented ,
          Used SSB with BMT-
          Code:

          void myAtomicProcess(String a, String b)throws MyException{
           try{
           userTx.begin()
           //2. update file ...
           fileOperFlag = true
           //1. update db...
           userTx.commit()
           DBoperFlag = true
          
           }catch(){}
           finally{
           if(fileOperFlag && !DBoperFlag){
           //Restore the file to its original state
           }
          
           }
          
          }
          




          Please let me know if you see any flaw in this.

          Regards,
          Sandeep Kulkarni