To execute a method outside of a transaction, you can write the code to perform either:
Execute the method before beginning a transaction, or
Temporarily stop and start execution of the transaction.
Execute tasks outside of a transaction using the suspend and resume methods
Execute suspend to temporarily stop execution of the transaction.
Execute the tasks.
Execute resume to restart the execution of the transaction from where it stopped.
This code fragment shows how to execute tasks outside of a transaction. The suspend method returns the control context. You specify the control context when you use the resume method to restart the transaction. Catch the InvalidControl exception, which may be raised when a control context is out of scope (and not null).
sus_ctrl = CurrentIntf->suspend(); /* The following method is not in the transaction */ component1->method2(); CurrentIntf->resume(sus_ctrl); /* The following methods are invoked in the transaction */ component2->method1(); CurrentIntf->commit(CS_FALSE); } catch(CosTransactions::SubtransactionsUnavailable &ex ) { cerr << "Exception: SubTxnUnavailable " << ex._jagExceptionCode << endl; } catch(CosTransactions::NoTransaction &ex ) { cerr << "Exception: NoTransaction " << ex._jagExceptionCode << endl; } catch(CosTransactions::InvalidControl &ex ) { cerr << "Exception: InvalidCtrol " << ex._jagExceptionCode << endl; } catch(...) { cerr << "Caught Unexpected exception" << endl; exit(-1); }