TMF Introduction (G06.24+)
TMF Application Programming
HP NonStop Transaction Management Facility (TMF) Introduction—522414-001
5-8
Controlling Transactions
Because timeout is detectable (the system issues a timeout error message), the
program can try the statement again, or abort the transaction and start the whole
transaction again.
Timeout can be used to detect deadlock in either an SQL database or an Enscribe
database. For applications using SQL tables, there is a default time limit that applies if
the application does not set one. For applications using Enscribe files, the application
must set a time limit; there is no default limit.
Controlling Transactions
The application programming interfaces to TMF include transaction control statements
that mark the beginning, committing, or backing out of a transaction.
The recommended application design is for the requester, rather than the server, to
handle transaction control; however, servers are responsible for backing out
transactions for some error conditions.
In general, applications should use single-threaded requesters and servers. A single-
threaded process is one that can deal with only one TMF transaction during any
specific period of time; in other words, the requester or server module never has more
than one transaction outstanding at a time.
Some applications, however, use multi-threaded requesters and servers. A multi-
threaded process is one that can deal with more than one TMF transaction
concurrently; it can, for instance, initiate multiple transactions and then switch
processing from one to another, or it can accept multiple work requests and then
alternately switch between one request and another.
Transaction Control for Single-Threaded Design
The syntax for transaction control varies, depending on the programming language and
API. See Table 2-1, Sample Transaction Control Statements, on page 2-8 for
transaction control statements for different programming languages and APIs. The
system procedure calls provide the most comprehensive interface to TMF for
transaction control:
•
BEGINTRANSACTION causes a new transaction identifier to be created. The new
transaction identifier becomes the current transaction identifier for the process that
called BEGINTRANSACTION.
•
ENDTRANSACTION causes the changes associated with the current transaction
identifier to be committed.
•
ABORTTRANSACTION causes the changes associated with the current
transaction identifier to be backed out. The program can restart the transaction at
the BEGINTRANSACTION call under a new transaction identifier.