Package com.swiftmq.swiftlet.queue
Class QueueTransaction
- java.lang.Object
-
- com.swiftmq.swiftlet.queue.QueueTransaction
-
- All Implemented Interfaces:
Recyclable
- Direct Known Subclasses:
QueuePullTransaction
,QueuePushTransaction
public abstract class QueueTransaction extends java.lang.Object implements Recyclable
Abstract base class for queue transactions.- Author:
- IIT GmbH, Bremen/Germany, Copyright (c) 2000-2002, All Rights Reserved
-
-
Constructor Summary
Constructors Constructor Description QueueTransaction()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
commit()
Commits the transaction and set the transaction state to closedvoid
commit(XidImpl globalTransactionId)
Commits a prepared transaction and set the transaction state to closed.AbstractQueue
getAbstractQueue()
CompositeStoreTransaction
getCompositeStoreTransaction()
Returns the current composite store transactionprotected AbstractQueue
getQueue()
Returns the queuejava.lang.String
getQueueName()
Returns the queue name of the underlying queueint
getRecycleIndex()
boolean
isClosed()
Returns the transaction stateboolean
isDoRollbackOnClose()
boolean
isPrepared()
Returns the prepared stateboolean
isQueueRunning()
boolean
isTemporaryQueue()
void
lockQueue()
Locks this queue and holds it until unlockQueue is called.void
prepare(XidImpl globalTransactionId)
Prepares the transaction with the given transaction id.void
reset()
abstract void
rollback()
Rolls back the transaction.abstract void
rollback(XidImpl globalTransactionId, boolean setRedelivered)
Rolls back the transaction with the given transaction id, eventually prepared under a global transaction id.void
setCompositeStoreTransaction(CompositeStoreTransaction ct)
Sets a CompositeStoreTransaction to be used as the current transaction.void
setDoRollbackOnClose(boolean doRollbackOnClose)
void
setRecycleIndex(int recycleIndex)
void
unlockQueue(boolean markAsyncActive)
Unlocks this queue.void
unmarkAsyncActive()
Unblocks this queue from async activeprotected void
verifyTransactionState()
Verifies the transaction state.
-
-
-
Method Detail
-
getAbstractQueue
public AbstractQueue getAbstractQueue()
-
isDoRollbackOnClose
public boolean isDoRollbackOnClose()
-
setDoRollbackOnClose
public void setDoRollbackOnClose(boolean doRollbackOnClose)
-
getRecycleIndex
public int getRecycleIndex()
- Specified by:
getRecycleIndex
in interfaceRecyclable
-
setRecycleIndex
public void setRecycleIndex(int recycleIndex)
- Specified by:
setRecycleIndex
in interfaceRecyclable
-
reset
public void reset()
- Specified by:
reset
in interfaceRecyclable
-
getQueueName
public java.lang.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 errorQueueTransactionClosedException
-
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 errorQueueTransactionClosedException
-
commit
public void commit() throws QueueException, QueueTransactionClosedException
Commits the transaction and set the transaction state to closed- Throws:
QueueException
- thrown by the queueQueueTransactionClosedException
- 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 flagsetRedelivered
is set then the JMS properties for redelivery and delivery count of messages pulled within this transaction are updated.- Parameters:
globalTransactionId
- global transaction idsetRedelivered
- specifies JMS redelivery setting- Throws:
QueueException
- on errorQueueTransactionClosedException
-
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 queueQueueTransactionClosedException
- 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
-
-