Current::rollback

Overview Rolls back the transaction associated with the current thread.
Original interface CosTransactions::Current Interface
Exceptions NoTransaction
NO_PERMISSION standard exception


Intended Usage

If there is no transaction associated with the current thread, the NoTransaction exception is raised. If the current thread does not have permission to rollback the transaction, the standard NO_PERMISSION exception is raised.

The effect of this request is equivalent to performing the rollback Operation in the corresponding Terminator Interface.

The current thread transaction is modified as follows: If the transaction has been begun by a thread (using begin) in the same execution environment, the thread's transaction context is restored to its state prior to the begin request. Otherwise, the thread's transaction context is set to NULL.

Syntax

void rollback() raises(NoTransaction); 

Input parameters

None.

Return values

Examples

The following examples demonstrate the usage of CosTransactions::Current::rollback.

C++ Example

  #include <CosTransactions.hh>    // CosTransactions module
  ...
  ::CORBA::Boolean    rollback_required = FALSE;
  ...
 
  //Access the CosTransactions::Current object.
   
  CORBA::Object_ptr orbCurrentPtr = 
     CBSeriesGlobal::orb()->resolve_initial_references("TransactionCurrent");
  CosTransactions::Current_ptr current = 
     CosTransactions::Current::_narrow(orbCurrentPtr);
 
  // Invoke the begin operation on the CosTransactions::Current object.
 
  current->begin();
 
  // Perform work for the transaction and set rollback_required to TRUE if 
  // an error is detected.
 
  ...
 
  // Invoke commit or rollback depending on whether rollback_required is 
  // set. This must be called within a try...catch structure as the 
  // transaction service may raise an exception if an error occurs.
 
  try
  {
      if (rollback_required == TRUE)
      {
          current->rollback();
      }
      else // commit required
      {
          current->commit(/* report_heuristics = */ TRUE);
      }
  }
  catch (CORBA::TRANSACTION_ROLLEDBACK  &exc)
  {
 
      // The application called commit, but the transaction service rolled
      // the transaction back because an error was detected.
 
      ...
  }
  catch (CosTransactions::HeuristicMixed  &exc)
  {
 
          // The transaction service has reported that some or all of the 
          // resourceobjects have made a heuristic decision.  This has 
          // resulted in heuristic damage.
 
          ...
  }
  catch (CosTransactions::HeuristicHazard  &exc)
  {
 
          // The transaction service has reported that not all of the 
          // resource objects could participate properly in determining the  
          // outcome of the transaction.  There is a possibility of 
          // heuristic damage.
 
          ...
  }
  catch (CORBA::UserException  &exc)
  {
          // Another type of user exception has occurred.
          ...
  }
  catch (CORBA::SystemException  &exc)
  {
          // The application called commit, but the transaction service 
          // rolledthe transaction back because an error was detected.
          
          ...
  }
  catch (...)
  {
          // A general exception has occurred.
          ...
  }
      ...

Related reference
CosTransactions in the transaction service



Searchable topic ID:   rcor_ctscu7
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/corba/ref/rcor_ctscu7.html

Library | Support | Terms of Use | Feedback