Home

Xid

Xid is an interface in Java that represents a global transaction identifier used in distributed transaction processing, notably under the X/Open XA standard and the Java Transaction API (JTA). It provides a way for a transaction manager to identify and coordinate a global transaction and its constituent branches across multiple resource managers such as databases and messaging systems.

A Xid consists of three components: a format identifier, a global transaction identifier (GTRID), and a branch

Usage of Xid occurs when resource managers interact with the transaction manager via the XAResource interface.

Implementation considerations: many transaction managers provide concrete Xid implementations. Applications typically obtain Xids from the transaction

See also: JTA, X/Open XA, XAResource, javax.transaction.xa.Xid.

qualifier
(BQUAL).
In
the
Java
Xid
interface,
these
correspond
to
getFormatId(),
getGlobalTransactionId(),
and
getBranchQualifier().
The
formatId
signals
the
encoding
scheme
used
by
the
transaction
manager
for
the
GTRID
and
BQUAL;
the
GTRID
uniquely
identifies
the
global
transaction
across
all
participating
resources;
the
BQUAL
distinguishes
a
particular
branch
or
subtransaction
within
that
global
transaction.
Both
the
GTRID
and
BQUAL
are
byte
arrays,
with
the
standard
allowing
up
to
a
certain
length
(commonly
up
to
64
bytes
each,
though
exact
limits
are
defined
by
the
implementation
and
the
XA
specification).
Methods
such
as
start,
end,
prepare,
commit,
and
rollback
use
a
Xid
to
identify
the
transaction
or
its
branches.
The
lifecycle
and
correctness
of
a
Xid
are
critical
for
ensuring
the
integrity
of
a
distributed
transaction
across
heterogeneous
resources.
manager
rather
than
implementing
Xid
themselves.
If
an
application
does
implement
Xid,
it
should
be
immutable,
provide
proper
equals
and
hashCode
semantics,
and
return
copies
of
byte
arrays
to
preserve
immutability.