Class QueueTransaction

java.lang.Object
com.swiftmq.swiftlet.queue.QueueTransaction
All Implemented Interfaces:
Recyclable
Direct Known Subclasses:
QueuePullTransaction, QueuePushTransaction

public abstract class QueueTransaction extends Object implements Recyclable
Abstract base class for queue transactions.
Author:
IIT GmbH, Bremen/Germany, Copyright (c) 2000-2002, All Rights Reserved
  • Constructor Details

    • QueueTransaction

      public QueueTransaction()
  • Method Details

    • getAbstractQueue

      public AbstractQueue getAbstractQueue()
    • isDoRollbackOnClose

      public boolean isDoRollbackOnClose()
    • setDoRollbackOnClose

      public void setDoRollbackOnClose(boolean doRollbackOnClose)
    • getRecycleIndex

      public int getRecycleIndex()
      Specified by:
      getRecycleIndex in interface Recyclable
    • setRecycleIndex

      public void setRecycleIndex(int recycleIndex)
      Specified by:
      setRecycleIndex in interface Recyclable
    • reset

      public void reset()
      Specified by:
      reset in interface Recyclable
    • getQueueName

      public String getQueueName()
      Returns the queue name of the underlying queue
      Returns:
      queue name
    • getQueue

      protected AbstractQueue getQueue()
      Returns the queue
      Returns:
      the queue
    • isQueueRunning

      public boolean isQueueRunning()
    • isTemporaryQueue

      public boolean isTemporaryQueue()
    • prepare

      public void prepare(XidImpl globalTransactionId) throws QueueException, QueueTransactionClosedException
      Prepares the transaction with the given transaction id. Messages are stored in the queue (on disk when persistent) but not unlocked. The preparation is logged under the global transaction id.
      Parameters:
      globalTransactionId - global transaction id
      Throws:
      QueueException - on error
      QueueTransactionClosedException
    • commit

      public void commit(XidImpl globalTransactionId) throws QueueException, QueueTransactionClosedException
      Commits a prepared transaction and set the transaction state to closed.
      Parameters:
      globalTransactionId - global transaction id
      Throws:
      QueueException - on error
      QueueTransactionClosedException
    • commit

      public void commit() throws QueueException, QueueTransactionClosedException
      Commits the transaction and set the transaction state to closed
      Throws:
      QueueException - thrown by the queue
      QueueTransactionClosedException - if the transaction was already closed
    • rollback

      public abstract void rollback(XidImpl globalTransactionId, boolean setRedelivered) throws QueueException, QueueTransactionClosedException
      Rolls back the transaction with the given transaction id, eventually prepared under a global transaction id. If the flag setRedelivered is set then the JMS properties for redelivery and delivery count of messages pulled within this transaction are updated.
      Parameters:
      globalTransactionId - global transaction id
      setRedelivered - specifies JMS redelivery setting
      Throws:
      QueueException - on error
      QueueTransactionClosedException
    • rollback

      public abstract void rollback() throws QueueException, QueueTransactionClosedException
      Rolls back the transaction. The transaction state should be set to closed.
      Throws:
      QueueException - thrown by the queue
      QueueTransactionClosedException - if the transaction was already closed
    • isClosed

      public boolean isClosed()
      Returns the transaction state
      Returns:
      true or false
    • isPrepared

      public boolean isPrepared()
      Returns the prepared state
      Returns:
      true or false
    • verifyTransactionState

      protected void verifyTransactionState() throws QueueTransactionClosedException
      Verifies the transaction state. If it is closed then a QueueTransactionClosedException will be thrown
      Throws:
      QueueTransactionClosedException - if the transaction is closed
    • lockQueue

      public void lockQueue()
      Locks this queue and holds it until unlockQueue is called.
    • unlockQueue

      public void unlockQueue(boolean markAsyncActive)
      Unlocks this queue.
      Parameters:
      markAsyncActive - blocks queue as async is active
    • unmarkAsyncActive

      public void unmarkAsyncActive()
      Unblocks this queue from async active
    • getCompositeStoreTransaction

      public CompositeStoreTransaction getCompositeStoreTransaction()
      Returns the current composite store transaction
      Returns:
      composite transaction
    • setCompositeStoreTransaction

      public void setCompositeStoreTransaction(CompositeStoreTransaction ct)
      Sets a CompositeStoreTransaction to be used as the current transaction. At the same time it disables prepare/commit/rollback calls inside this queue so that multiple queues can use the same transaction and prepare/commit/rollback is done outside.
      Parameters:
      ct - composite transaction