Skip navigation links

Oracle Fusion Middleware
Java API Reference for Oracle WebLogic Server
12c (12.2.1)

Part Number E55141-01
P4 Change 1723563 on 2015/10/09


weblogic.transaction
Interface Transaction

All Superinterfaces:
Transaction

public interface Transaction
extends Transaction

This interface provides extensions to the javax.transaction.Transaction object for application or system use.

Transaction Properties

Transaction properties are key/value pairs. Once set, they remain associated with a transaction during its entire lifetime. They are propagated between machines as the transaction travels through the system. They also are saved in the transaction log, and restored during crash recovery processing.

If a transaction property is set more than once the latest value is retained. However, in some threaded and/or multi-server situations, this behavior may not be predictable.

Key names prefixed with "weblogic.transaction" are reserved for use by Oracle.

Transaction Status

Recovery and audit-trail procedures require more information about a transaction than the JTA Transaction interface furnishes; information such as the transaction identifier, the specific reason for a rollback, and any heuristic error messages. In addition, the time taken by the transaction and the amount of time left can be used as limits on certain operations.

See Also:
Transaction

Field Summary
static String ENLISTMENT_RESOURCE_TYPE
          The transaction property key that is used internally as the enlisted resource type (such as Weblogic JMS, see ENLISTMENT_RESOURCE_TYPE_WEBLOGIC_JMS) for a transaction.
static String ENLISTMENT_RESOURCE_TYPE_WEBLOGIC_JMS
          A transaction value to the ENLISTMENT_RESOURCE_TYPE key indicating the enlisted resource is a WebLogic JMS resource
static String TRANSACTION_COMPLETION_TIMEOUT_SECONDS_PROPERTY_KEY
          The transaction property key that is used internally as the completion-timeout-seconds override for a transaction.
static String TRANSACTION_EAGER_END_ON_DELIST_PROPERTY_KEY
          The transaction property key that is used internally to indicate, via boolean value, whether XAResource.end must be called immediately rather than deferred.
static String TRANSACTION_NAME_PROPERTY_KEY
          The transaction property key that is used internally to store the name associated with a transaction.

 

Method Summary
abstract  void addProperties(Map props)
          Adds a set of properties to a transaction by calling setProperty for all elements of props.
abstract  boolean delistResourceWithProperties(XAResource xaRes, int flags, Map delistmentProperties)
          Delist a Resource with specific properties in the transaction.
abstract  boolean enlistResource(NonXAResource nxar)
          Enlist a Non-XA Resource in the transaction.
abstract  boolean enlistResourceWithProperties(XAResource xaRes, Map enlistmentProperties)
          Enlist a Resource with specific properties in the transaction.
abstract  String getHeuristicErrorMessage()
          Returns the heuristic error message (if any) associated with the transaction.
abstract  long getMillisSinceBegin()
          Returns the amount of time, in milliseconds, that the transaction has been in existence.
abstract  String getName()
          Retrieves the name previously associated with a transaction.
abstract  Map getProperties()
          Gets all properties currently associated with a transaction.
abstract  Serializable getProperty(String key)
          Gets the value of a specific property.
abstract  Throwable getRollbackReason()
          Retrieves the rollback reason (if any) associated with the transaction.
abstract  String getStatusAsString()
          Returns the status of the transaction as a string.
abstract  long getTimeToLiveMillis()
          Returns the amount of time, in milliseconds, that the transaction has left to go.
abstract  Xid getXid()
           
abstract  Xid getXID()
          Gets the transaction identifier.
abstract  boolean isTimedOut()
          Returns true if the transaction has timed out, false otherwise.
abstract  boolean isTxAsyncTimeout()
           
abstract  void setName(String n)
          Associates a name with a transaction.
abstract  void setProperty(String key, Serializable value)
          Sets a property value to be associated with a transaction.
abstract  void setRollbackOnly(String msg)
          Wraps the rollback string message and calls setRollbackOnly with this new message.
abstract  void setRollbackOnly(String msg, Throwable reason)
          Wraps the rollback string message and the exception and calls setRollbackOnly with this new exception.
abstract  void setRollbackOnly(Throwable reason)
          Provides a reason for the rollback.

 

Methods inherited from interface javax.transaction.Transaction
commit, delistResource, enlistResource, getStatus, registerSynchronization, rollback, setRollbackOnly

 

Field Detail

TRANSACTION_NAME_PROPERTY_KEY

static final String TRANSACTION_NAME_PROPERTY_KEY
The transaction property key that is used internally to store the name associated with a transaction. A transaction name (a String) may be assigned to a transaction using either the setName or setProperty methods.
See Also:
Transaction.setName(java.lang.String), Transaction.setProperty(java.lang.String, java.io.Serializable), Constant Field Values

TRANSACTION_COMPLETION_TIMEOUT_SECONDS_PROPERTY_KEY

static final String TRANSACTION_COMPLETION_TIMEOUT_SECONDS_PROPERTY_KEY
The transaction property key that is used internally as the completion-timeout-seconds override for a transaction.
See Also:
Constant Field Values

ENLISTMENT_RESOURCE_TYPE

static final String ENLISTMENT_RESOURCE_TYPE
The transaction property key that is used internally as the enlisted resource type (such as Weblogic JMS, see ENLISTMENT_RESOURCE_TYPE_WEBLOGIC_JMS) for a transaction.
See Also:
Constant Field Values

ENLISTMENT_RESOURCE_TYPE_WEBLOGIC_JMS

static final String ENLISTMENT_RESOURCE_TYPE_WEBLOGIC_JMS
A transaction value to the ENLISTMENT_RESOURCE_TYPE key indicating the enlisted resource is a WebLogic JMS resource
See Also:
Constant Field Values

TRANSACTION_EAGER_END_ON_DELIST_PROPERTY_KEY

static final String TRANSACTION_EAGER_END_ON_DELIST_PROPERTY_KEY
The transaction property key that is used internally to indicate, via boolean value, whether XAResource.end must be called immediately rather than deferred.
See Also:
Constant Field Values

Method Detail

setName

void setName(String n)
Associates a name with a transaction. The name is typically used to describe a type of transaction and is not meant for describing each individual transaction. All internally generated error reports incorporate the name if present. Once set, the name cannot be changed.

getName

String getName()
Retrieves the name previously associated with a transaction.
Returns:
Transaction name

setProperty

void setProperty(String key,
                 Serializable value)
Sets a property value to be associated with a transaction.
Parameters:
key - A string key
value - Property value, null means delete

addProperties

void addProperties(Map props)
Adds a set of properties to a transaction by calling setProperty for all elements of props.
Parameters:
props - Set of key/value pairs to add

getProperty

Serializable getProperty(String key)
Gets the value of a specific property.
Parameters:
key - Property name
Returns:
Value of property or null if unset

getProperties

Map getProperties()
Gets all properties currently associated with a transaction.
Returns:
Map containing all key/value pairs

setRollbackOnly

void setRollbackOnly(Throwable reason)
Provides a reason for the rollback. All rollbacks triggered inside the transaction service set the reason (timeouts, XA errors, unchecked exceptions in beforeCompletion, inability to contact the coordinator, etc.) Once set, the reason cannot be overwritten.
Parameters:
reason - the reason behind the rollback.

setRollbackOnly

void setRollbackOnly(String msg,
                     Throwable reason)
Wraps the rollback string message and the exception and calls setRollbackOnly with this new exception.
Parameters:
reason - the reason behind the rollback.
See Also:
Transaction.setRollbackOnly(Throwable)

setRollbackOnly

void setRollbackOnly(String msg)
Wraps the rollback string message and calls setRollbackOnly with this new message.
Parameters:
msg - the message behind the rollback.
See Also:
Transaction.setRollbackOnly(Throwable)

getRollbackReason

Throwable getRollbackReason()
Retrieves the rollback reason (if any) associated with the transaction.
Returns:
the rollback reason (if any) associated with the transaction.
See Also:
Transaction.setRollbackOnly(Throwable reason)

getHeuristicErrorMessage

String getHeuristicErrorMessage()
Returns the heuristic error message (if any) associated with the transaction.

getXID

Xid getXID()
Gets the transaction identifier. It is important to know that the transaction adds some extra information to the Xid's gtrid and branch qualifier (bqual) when it calls a resource, so calls to tx.getXID().getGlobalTransactionId() before calling a resource (for the first time) and then subsequently differ in what is returned. There are two guarantees provided: 1. xid.equals() is not affected. An xid obtained from tx.getXID() and another obtained at a subsequent time are considered equal (for the same tx, of course). As mentioned earlier, this guarantee is not extended to the constituents of the xid, namely the gtrid and the bqual. 2. An XA resource will always be supplied the same xid (with the same gtrid and bqual) for a given transaction, in all its XAResource methods.
Returns:
Transaction identifier

getXid

Xid getXid()
See Also:
Transaction.getXID()

getStatusAsString

String getStatusAsString()
Returns the status of the transaction as a string. The string contains the major state as specified in javax.transaction.Status, further embellished with a minor state (such as "logging", "pre-preparing", etc.)
Returns:
Transaction status in string form

getMillisSinceBegin

long getMillisSinceBegin()
Returns the amount of time, in milliseconds, that the transaction has been in existence. This value may not include network propagation time because there is no expectation of synchronized clocks.
Returns:
Existence time of transaction, in milliseconds

getTimeToLiveMillis

long getTimeToLiveMillis()
Returns the amount of time, in milliseconds, that the transaction has left to go. This time is meaningful only when the transaction is active, not when it is retrying commit or rollback.
Returns:
Time remaining for transaction, in milliseconds

isTimedOut

boolean isTimedOut()
Returns true if the transaction has timed out, false otherwise.

isTxAsyncTimeout

boolean isTxAsyncTimeout()

enlistResourceWithProperties

boolean enlistResourceWithProperties(XAResource xaRes,
                                     Map enlistmentProperties)
                                     throws RollbackException,
                                            IllegalStateException,
                                            SystemException
Enlist a Resource with specific properties in the transaction.
Throws:
RollbackException
IllegalStateException
SystemException

enlistResource

boolean enlistResource(NonXAResource nxar)
                       throws RollbackException,
                              IllegalStateException,
                              SystemException
Enlist a Non-XA Resource in the transaction.
Throws:
RollbackException
IllegalStateException
SystemException

delistResourceWithProperties

boolean delistResourceWithProperties(XAResource xaRes,
                                     int flags,
                                     Map delistmentProperties)
                                     throws IllegalStateException,
                                            SystemException
Delist a Resource with specific properties in the transaction.
Throws:
IllegalStateException
SystemException

Skip navigation links

Copyright 1996, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Oracle Fusion Middleware
Java API Reference for Oracle WebLogic Server
12c (12.2.1)

Part Number E55141-01
P4 Change 1723563 on 2015/10/09