Package com.swiftmq.swiftlet.queue
Class QueueTransaction
java.lang.Object
com.swiftmq.swiftlet.queue.QueueTransaction
- All Implemented Interfaces:
Recyclable
- Direct Known Subclasses:
QueuePullTransaction
,QueuePushTransaction
Abstract base class for queue transactions.
- Author:
- IIT GmbH, Bremen/Germany, Copyright (c) 2000-2002, All Rights Reserved
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
commit()
Commits the transaction and set the transaction state to closedvoid
Commits a prepared transaction and set the transaction state to closed.Returns the current composite store transactionprotected AbstractQueue
getQueue()
Returns the queueReturns the queue name of the underlying queueint
boolean
isClosed()
Returns the transaction stateboolean
boolean
Returns the prepared stateboolean
boolean
void
Locks this queue and holds it until unlockQueue is called.void
Prepares the transaction with the given transaction id.void
reset()
abstract void
rollback()
Rolls back the transaction.abstract void
Rolls back the transaction with the given transaction id, eventually prepared under a global transaction id.void
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
Unblocks this queue from async activeprotected void
Verifies the transaction state.
-
Constructor Details
-
QueueTransaction
public QueueTransaction()
-
-
Method Details
-
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
Returns the queue name of the underlying queue- Returns:
- queue name
-
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
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
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
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
Returns the current composite store transaction- Returns:
- composite transaction
-
setCompositeStoreTransaction
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
-