The Transaction Manager can be used to create a new transaction.
There are 2 types of Transaction Managers:
Respectively, the methods to retrieve a Transaction Manager are:
Sample usage:
SpaceFinder spaceFinder;
SpaceProxyPtr SpaceProxy = spaceFinder.find("jini://lookup-host/container-name/space-name");
ITransactionManagerPtr localTxnMgr = SpaceProxy->getLocalTransactionManager();
TransactionPtr txn = localTxnMgr->create();
// ...
// Use the transaction to perform space operations
// ...
txn->commit();
Here is an example of creating and using a distributed transaction based on Jini Mahalo (note the use of Config object):
#define LOOKUP_GROUPS "MY-LOOKUP-GROUPS"
SpaceFinder spaceFinder;
SpaceProxyPtr SpaceProxy = spaceFinder.find("jini://lookup-host/container-name/space-name");
IConfigPtr config(new JiniConfig("", "", LOOKUP_GROUPS));
ITransactionManagerPtr distTxnMgr = SpaceProxy->getDistributedTransactionManager(config);
TransactionPtr txn = distTxnMgr->create();
// ...
// Use the transaction to perform space operations
// ...
txn->commit();
Public Member Functions | |
virtual TransactionPtr | create (long long leaseTime=60000)=0 |
Creates a new Transaction. |
virtual TransactionPtr ITransactionManager::create | ( | long long | leaseTime = 60000 |
) | [pure virtual] |
Creates a new Transaction.
The type of the new Transaction is determined by the type of the Transaction Manager (Local vs. Distributed)
leaseTime | - The time period in milliseconds until the Transaction is discarded. Default is 60 seconds. |
RemoteException | - if a communication error occurs | |
LeaseDeniedException | - if the requested leaseTime is denied |