e-docs > Tuxedo > CORBA ActiveX Online Help > Using Transactions |
CORBA ActiveX Online Help |
Using Transactions
This Help topic describes how to use transactions in ActiveX client applications for the BEA Tuxedo CORBA.
For an overview of the TransactionCurrent object, see Chapter 1, "Overview."
Overview of Transactions
Client applications use transaction processing to ensure that data remains correct, consistent, and persistent. The transactions in BEA Tuxedo CORBA allow client applications to begin and terminate transactions and to get the status of transactions. The BEA Tuxedo software uses transactions as defined in the CORBAservices Object Transaction Service, with extensions for ease of use.
Transactions are defined on interfaces. The application designer decides which interfaces within a BEA Tuxedo client/server application will handle transactions. Transaction policies are defined in the Implementation Configuration File (ICF) for C++ server applications. Generally, the ICF file or the Server Description file for the available interfaces is provided to the client programmer by the application designer.
Summary of the Development Process for Transactions
The steps for adding transactions to a client application are as follows:
The following sections describe these steps and use portions of the client applications in the Transactions University sample application to illustrate the steps. For information about the Transactions University sample application, see the Guide to the CORBA University Sample Applications in the BEA Tuxedo online documentation. The Transactions University sample application is located in the following directory on the BEA Tuxedo software kit: drive:\tuxdir\samples\corba\university\transactions
Step 1: Using the Bootstrap Object to Obtain the TransactionCurrent Object
Use the Bootstrap object to obtain an object reference to the TransactionCurrent object for the specified BEA Tuxedo domain. For a complete description of the TransactionCurrent object, see the CORBA Programming Reference in the BEA Tuxedo online documentation.
The following Visual Basic example illustrates how the Bootstrap object is used to return the TransactionCurrent object:
Set objTransactionCurrent =
objBootstrap.CreateObject("Tobj.TransactionCurrent")
Step 2: Using the TransactionCurrent Methods
The TransactionCurrent object has methods that allow a client application to manage transactions. These methods can be used to begin and end transactions and to obtain information about the current transaction. The TransactionCurrent object provides the following methods:
Creates a new transaction. Future operations take place within the scope of this transaction. When a client application begins a transaction, the default transaction timeout is 300 seconds. You can change this default, using the set_timeout method.
Ends the transaction successfully. Indicates that all operations on this client application have completed successfully.
Forces the transaction to roll back.
Marks the transaction so that the only possible action is to roll back. Generally, this method is used only in server applications.
Suspends participation in the current transaction. This method returns an object that identifies the transaction and allows the client application to resume the transaction later.
Resumes participation in the specified transaction.
Returns the status of a transaction with a client application.
Returns a printable string describing the transaction.
Modifies the timeout period associated with transactions. The default transaction timeout value is 300 seconds. If a transaction is automatically started instead of explicitly started with the begin() method, the timeout value is determined by the value of the TRANTIME parameter in the UBBCONFIG file. For more information about setting the TRANTIME parameter, see Administering a BEA Tuxedo Application at Run Time in the BEA Tuxedo online documentation.
Returns a control object that represents the transaction.
A basic transaction works in the following way:
' Begin the transaction
'
objTransactionCurrent.begin
'
' Try to register for courses
'
NotRegisteredList = objRegistrar.register_for_courses(mStudentID,
CourseList, exception)
'
If exception.EX_majorCode = NO_EXCEPTION then
' Request succeeded, commit the transaction
'
Dim report_heuristics As Boolean
report_heuristics = True
objTransactionCurrent.commit report_heuristics
Else
' Request failed, Roll back the transaction
'
objTransactionCurrent.rollback
MsgBox "Transaction Rolled Back"
End If