Oracle7 Server Distributed Systems Volume I: Distributed Data

Contents Index Home Previous Next

XA Library Thread Safety

If you use a transaction monitor that supports threads, the Oracle XA library allows you to write applications that are thread safe. Certain issues must be kept in mind, however.

A thread of control (or thread) refers to the set of connections to resource managers. In an unthreaded system, each process could be considered a thread of control, since each process has its own set of connections to resource managers and each process maintains its own independent resource manager table.

In a threaded system, each thread has an autonomous set of connections to resource managers and each thread maintains a private resource manager table. This private resource manager table must be allocated for each new thread and deallocated when the thread terminates, even if the termination is abnormal.

Note that, in an Oracle system, once a thread has been started and establishes a connection, only that thread can use that connection. No other thread can make a call to that connection.

The Open String Specification

The xa_open string parameter, xa_info, provides the clause, Threads=, which must be specified as true to enable the use of threads by the transaction monitor. The default is false.

OCI Clients

The open string parameter, Threads, must be specified as yes and the client must written to allocate new logon area (LDA). Note that, in most cases, threads will be created by the transaction monitor and that the application will not know when a new thread is created. Therefore, it is advisable to allocate an LDA on the stack within each service that is written for a transaction monitor application. Before doing any Oracle-related calls in that service, the sqlld2 function must be called and the LDA initialized. This LDA can then be used for all OCI calls within that service.

Restrictions

The following restrictions apply when you are using threads:


Contents Index Home Previous Next