Using transaction state primitives

EAServer provides transaction state primitives that methods can call to direct the outcome of the current transaction. Each component model provides an interface containing methods for these primitives. Table 2-2 lists the API mappings for each component type.

These methods end a component’s participation in a transaction (both cause the current instance to be deactivated):

These methods are used to maintain state after the method returns (they delay deactivation of the component instance):

These primitives can be used to query the state of the transaction (if any) in which the method is executing:

Table 2-2 describes how the transaction primitives are invoked in Java and PowerBuilder components. For information on the Java methods, see Chapter 1, “Java Classes and Interfaces,” in the EAServer API Reference. For information on the PowerBuilder TransactionServer object, see the Application Techniques manual in the PowerBuilder documentation and the PowerBuilder online help.

Table 2-2: Java and PowerBuilder transaction primitives

Transaction primitive

Java InstanceContext

method

PowerBuilder TransactionServer function

completeWork

completeWork

SetComplete

rollbackWork

rollbackWork

SetAbort

continueWork

continueWork

EnableCommit

disallowCommit

None. You can achieve the same effect by calling, and then raising an exception if deactivate is called before the next method invocation.

DisableCommit

isInTransaction

inTransaction

IsInTransaction

isRollbackOnly

isRollbackOnly

IsTransactionAborted

C and C++ components call the methods and routines in the following table to invoke transaction primitives. See the EAServer API Reference for documentation of these methods and routines:

Table 2-3: C and C++ transaction primitives

Transaction primitive

C/C++ routine

completeWork

JagCompleteWork

rollbackWork

JagRollbackWork

continueWork

JagContinueWork

disallowCommit

JagDisallowCommit

isInTransaction

JagInTransaction

isRollbackOnly

JagIsRollbackOnly

Any participating component can roll back the transaction by calling the rollbackWork primitive; Java components can also cause a rollback by returning an unhandled exception. Only the action of the root component determines when EAServer commits the transaction. The transaction is committed when the root component returns with a state of completeWork and no participating component has set a state of disallowCommit.

You can use the transaction state primitives in any component; the component does not have to be declared transactional. Calling completeWork or rollbackWork from methods causes early deactivation. “Supporting early deactivation in your component” discusses how this feature can improve application performance.