// get reference to the Current
...
// begin a transaction
current->begin();
// create a dynamic request
CORBA::Request_var bankRequest = bank->_request("withdraw");
CORBA::NVList_ptr arguments = bankRequest->arguments();
CORBA::Any_var amt = new CORBA::Any();
*amt<<= ((float)1000.00);
arguments->add_value("amount", amt, CORBA::ARG_IN);
...
//invoke deferred synchronous request
bankRequest->send_deferred();
//forget to get the response
// commit the txn
try
{
current->commit(0);
}
catch(CORBA::TRANSACTION_ROLLEDBACK& e)
{
cerr << "SUCCESS, commit check worked()" << endl;
}
...The example below shows the client code for checked behavior when you have a deferred synchronous request and the reply returns before commit() is invoked. Checked behavior is successful—the transaction is committed....
// case where request arrived before commit
current->begin();
cerr << " === Invoking a dii deferred sync request" << endl;
bankRequest->send_deferred();
try {
//wait for reply
bankRequest->get_response();
current->commit(0);
}
catch(CORBA::TRANSACTION_ROLLEDBACK& e)
{
cerr << "FAILURE, TRANSACTION_ROLLEDBACK not expected" << endl;
}
}