Interface XAContext


public interface XAContext
This class acts as a context for an XA transaction. Multiple so-called 'threads of control' (ToC) can share an XAContext. Before they access it, they have to register itself to become associated with the XA transaction. Thereafter they do their work and add QueueTransactions to this context before they unregister. If no more ToCs are registered with the XAContext, the 2-phase-commit protocol is used to finish the transaction.
Author:
IIT GmbH, Bremen/Germany, Copyright (c) 2000-2003, All Rights Reserved
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addTransaction(int id, String queueName, QueueTransaction transaction)
    Add a QueueTransaction to the XA transaction.
    void
    Closes this XAContext.
    long
    commit(boolean onePhase)
    Performs a commit operation on all registered QueueTransactions.
    Returns the Xid.
    boolean
    Returns whether this transaction is in the 'prepared' state.
    boolean
    Returns whether this transaction was recovered on startup from the prepared log
    void
    Performs a prepare operation on all registered QueueTransactions.
    int
    register(String description)
    Registers a new Thread of Control at this XAContext.
    void
    Performs a rollback operation on all registered QueueTransaction.
    void
    setPrepared(boolean b)
    Sets this context to the 'prepared' state
    void
    unregister(int id, boolean rollbackOnly)
    Unregisters a ToC from this XAContext.
  • Method Details

    • getXid

      XidImpl getXid()
      Returns the Xid.
      Returns:
      xid.
    • isPrepared

      boolean isPrepared()
      Returns whether this transaction is in the 'prepared' state.
      Returns:
      true/false
    • setPrepared

      void setPrepared(boolean b)
      Sets this context to the 'prepared' state
      Parameters:
      b - true/false
    • isRecovered

      boolean isRecovered()
      Returns whether this transaction was recovered on startup from the prepared log
      Returns:
      true/false
    • register

      int register(String description) throws XAContextException
      Registers a new Thread of Control at this XAContext.
      Parameters:
      description - A description of the ToC
      Returns:
      id ToC id
      Throws:
      XAContextException - on error
    • addTransaction

      void addTransaction(int id, String queueName, QueueTransaction transaction) throws XAContextException
      Add a QueueTransaction to the XA transaction. This has to be done while the ToC is registered.
      Parameters:
      id - the ToC id
      queueName - Name of the queue
      transaction - QueueTransaction
      Throws:
      XAContextException - on error
    • unregister

      void unregister(int id, boolean rollbackOnly) throws XAContextException
      Unregisters a ToC from this XAContext.
      Parameters:
      id - ToC id
      rollbackOnly - marks this transaction as rollback only
      Throws:
      XAContextException - on error
    • prepare

      void prepare() throws XAContextException
      Performs a prepare operation on all registered QueueTransactions. All ToCs have to be unregistered to this.
      Throws:
      XAContextException - on error
    • commit

      long commit(boolean onePhase) throws XAContextException
      Performs a commit operation on all registered QueueTransactions. If 'onePhase' is set to true, a normal commit is performed, otherwise a 2PC commit is performed. All ToCs have to be unregistered to this. For 2PC commit the XAContext has to be in the prepared state (isPrepared() must return true).
      Parameters:
      onePhase - perform a 1PC commit.
      Returns:
      Flowcontrol delay
      Throws:
      XAContextException - on error.
    • rollback

      void rollback() throws XAContextException
      Performs a rollback operation on all registered QueueTransaction. If the XAContext is in the prepared state (isPrepared() return true), a 2PC rollback is performed, otherwise a 1PC rollback (normal rollback) is performed. All ToCs have to be unregistered to this.
      Throws:
      XAContextException
    • close

      void close()
      Closes this XAContext. This method is called when the XAResourceManagerSwiftlet shuts down. If the XAContext is not in the prepared state, a normal rollback is performed on all registered QueueTransactions.