lr.start_transaction

Marks the beginning of a transaction.

int lr.start_transaction( String transaction_name ); 
Transaction FunctionsJava Syntax

Arguments

NameComments
transaction_name The name of the transaction.

The lr.start_transaction function marks the beginning of a transaction. To indicate a transaction to be analyzed, use the lr.start_transaction and lr.end_transaction functions. These functions are inserted immediately before and after the transaction.

Transactions can be nested, but each lr.start_transaction statement must be associated with an lr.end_transaction statement or it will be interpreted as an illegal command.

Note: For information on allowed characters and maximum length for transaction names, see Transaction guidelines in the Virtual User Generator Help Center.

Return Values

This function returns 0 if it succeeds. It returns -1 if the transaction name is illegal.

Parameterization

Parameterization is not applicable to this function.

Example

The sample below illustrates timing the duration of a method call getStockList from an ORB interface. It adds checks for exceptions and ensures that the getStockList method returns an non-zero length array.

lr.start_transaction("GetStocks");

try { String stocks[];

stocks = orStockServer1.getStockList();

if (stocks.length == 0)          throw new Exception("No stocks returned/available");

lr.end_transaction("GetStocks", lr.PASS);

}
catch (Exception e1) {
    lr.end_transaction("GetStocks", lr.FAIL);
    lr.message(" An exception occurred : " + e1.toString() );
    }