Class LocalQueue
- java.lang.Object
-
- net.timewalker.ffmq4.local.destination.AbstractLocalDestination
-
- net.timewalker.ffmq4.local.destination.LocalQueue
-
- All Implemented Interfaces:
javax.jms.Destination,javax.jms.Queue,LocalDestinationMBean,LocalQueueMBean,DestinationDescriptorMBean,Committable,ActiveObject
public final class LocalQueue extends AbstractLocalDestination implements javax.jms.Queue, LocalQueueMBean, ActiveObject
Implementation for a local JMS
Queue
-
-
Field Summary
-
Fields inherited from class net.timewalker.ffmq4.local.destination.AbstractLocalDestination
closed, closeLock, consumersLock, destinationDef, localConsumers, transactionLock
-
-
Constructor Summary
Constructors Constructor Description LocalQueue(FFMQEngine engine, QueueDefinition queueDef)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AbstractMessagebrowse(LocalQueueBrowserCursor cursor, MessageSelector selector)Browse a message in this queuevoidclose()Release destination resourcesvoidcommitChanges(SynchronizationBarrier barrier)Commit all changes (make sure they are really applied) (ASYNCHRONOUS)AbstractMessageget(LocalSession localSession, TransactionSet transactionSet, MessageSelector selector)Get the first available message from this destination (matching an optional message selector).longgetAcknowledgedGetCount()Get the number of acknowledged get operations on this queue (since startup or last reset)QueueDefinitiongetDefinition()Get the queue definitionlonggetExpiredCount()Get the number of messages that were removed from this queue because they expired (since startup or last reset)longgetLastActivity()Get a timestamp of this object's last activityintgetMemoryStoreUsage()Get the usage amount (%) for the memory storeintgetPersistentStoreUsage()Get the usage amount (%) for the memory storeStringgetQueueName()longgetReceivedFromQueueCount()Get the number of messages received from this queue (since startup or last reset)longgetRollbackedGetCount()Get the number of rollbacked get operations on this queue (since startup or last reset)longgetSentToQueueCount()Get the number of messages sent to this queue (since startup or last reset)intgetSize()Get the destination size (number of contained messages)longgetStoreFullEventsCount()Get the number of times a message could not be stored because the queue store was fulllonggetTimeoutDelay()Get the maximum allowed time between activitiesprotected booleanhasPendingChanges()Test if this destinations still has some uncommitted changesbooleanonActivityTimeout()Called if the object has been inactive for moreprotected voidprocessAvailabilityNotificationQueue()voidpurge(MessageSelector selector)Purge some messages from the bufferbooleanputLocked(AbstractMessage message, LocalSession session, MessageLockSet locks)Put a new message in the destination.booleanredeliverLocked(TransactionItem[] items, MessageLockSet locks)Rollback get operations on this queue (messages are unlocked)..protected voidredeliverMessage(AbstractMessage msg, MessageStore store, int handle)See RedeliveryTaskbooleanremove(LocalSession localSession, TransactionItem[] items)Commit get operations on this queue (messages are removed)voidremoveLocked(MessageLock lockRef)Remove a locked message from this queue.protected booleanrequiresTransactionalUpdate()Test if this destination requires transactional semantics to be updatedvoidresetStats()Reset statistics on this destinationStringtoString()voidunlockAndDeliver(MessageLock lockRef)Unlock a message.-
Methods inherited from class net.timewalker.ffmq4.local.destination.AbstractLocalDestination
checkNotClosed, checkTransactionLock, closeTransaction, commitChanges, getAutoExtendAmount, getAverageCommitTime, getBlockSize, getInitialBlockCount, getJournalOutputBuffer, getMaxBlockCount, getMaxCommitTime, getMaxJournalSize, getMaxNonPersistentMessages, getMaxUncommittedStoreSize, getMaxUnflushedJournalSize, getMaxWriteBatchSize, getMinCommitTime, getName, getRegisteredConsumersCount, getStorageSyncMethod, isClosed, isConsumerRegistered, isPreAllocateFiles, isTemporary, isUseJournal, lookupConsumer, notifyCommitTime, openTransaction, registerConsumer, unregisterConsumer
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.timewalker.ffmq4.management.destination.DestinationDescriptorMBean
getAutoExtendAmount, getBlockSize, getInitialBlockCount, getJournalOutputBuffer, getMaxBlockCount, getMaxJournalSize, getMaxNonPersistentMessages, getMaxUncommittedStoreSize, getMaxUnflushedJournalSize, getMaxWriteBatchSize, getName, getStorageSyncMethod, isPreAllocateFiles, isTemporary, isUseJournal
-
Methods inherited from interface net.timewalker.ffmq4.local.destination.LocalDestinationMBean
getAverageCommitTime, getMaxCommitTime, getMinCommitTime, getRegisteredConsumersCount
-
-
-
-
Constructor Detail
-
LocalQueue
public LocalQueue(FFMQEngine engine, QueueDefinition queueDef) throws javax.jms.JMSException
Constructor- Throws:
javax.jms.JMSException
-
-
Method Detail
-
getDefinition
public QueueDefinition getDefinition()
Get the queue definition
-
getQueueName
public String getQueueName()
- Specified by:
getQueueNamein interfacejavax.jms.Queue
-
putLocked
public boolean putLocked(AbstractMessage message, LocalSession session, MessageLockSet locks) throws javax.jms.JMSException
Description copied from class:AbstractLocalDestinationPut a new message in the destination. The message is locked and the lock registered in the provided lock set- Specified by:
putLockedin classAbstractLocalDestination- Returns:
- true if a commit is required to ensure data safety
- Throws:
javax.jms.JMSException
-
unlockAndDeliver
public void unlockAndDeliver(MessageLock lockRef) throws javax.jms.JMSException
Unlock a message. Listeners are automatically notified of the new message availability.- Throws:
javax.jms.JMSException
-
removeLocked
public void removeLocked(MessageLock lockRef) throws javax.jms.JMSException
Remove a locked message from this queue. The message is deleted from the underlying store.- Throws:
javax.jms.JMSException
-
remove
public boolean remove(LocalSession localSession, TransactionItem[] items) throws javax.jms.JMSException
Commit get operations on this queue (messages are removed)- Returns:
- true if a store commit is required to ensure data safety
- Throws:
javax.jms.JMSException
-
redeliverLocked
public boolean redeliverLocked(TransactionItem[] items, MessageLockSet locks) throws javax.jms.JMSException
Rollback get operations on this queue (messages are unlocked).. Consumers are notified of rollbacked messages availability- Returns:
- true if a commit is required to ensure data safety
- Throws:
javax.jms.JMSException
-
commitChanges
public void commitChanges(SynchronizationBarrier barrier) throws javax.jms.JMSException
Description copied from interface:CommittableCommit all changes (make sure they are really applied) (ASYNCHRONOUS)- Specified by:
commitChangesin interfaceCommittable- Parameters:
barrier- a synchronization barrier- Throws:
javax.jms.JMSException
-
redeliverMessage
protected void redeliverMessage(AbstractMessage msg, MessageStore store, int handle)
See RedeliveryTask
-
get
public AbstractMessage get(LocalSession localSession, TransactionSet transactionSet, MessageSelector selector) throws javax.jms.JMSException
Get the first available message from this destination (matching an optional message selector). If a message is found, the transaction set is updated accordingly.- Returns:
- a message or null if there is no available message (or queue is closed)
- Throws:
javax.jms.JMSException
-
browse
public AbstractMessage browse(LocalQueueBrowserCursor cursor, MessageSelector selector) throws javax.jms.JMSException
Browse a message in this queue- Parameters:
cursor- browser cursorselector- a message selector or null- Returns:
- a matching message or null
- Throws:
javax.jms.JMSException- on internal error
-
purge
public void purge(MessageSelector selector) throws javax.jms.JMSException
Purge some messages from the buffer- Throws:
javax.jms.JMSException
-
getSize
public int getSize()
Description copied from interface:LocalDestinationMBeanGet the destination size (number of contained messages)- Specified by:
getSizein interfaceLocalDestinationMBean
-
getMemoryStoreUsage
public int getMemoryStoreUsage()
Description copied from interface:LocalQueueMBeanGet the usage amount (%) for the memory store- Specified by:
getMemoryStoreUsagein interfaceLocalQueueMBean
-
getPersistentStoreUsage
public int getPersistentStoreUsage()
Description copied from interface:LocalQueueMBeanGet the usage amount (%) for the memory store- Specified by:
getPersistentStoreUsagein interfaceLocalQueueMBean
-
resetStats
public void resetStats()
Description copied from interface:LocalDestinationMBeanReset statistics on this destination- Specified by:
resetStatsin interfaceLocalDestinationMBean- Overrides:
resetStatsin classAbstractLocalDestination
-
toString
public String toString()
-
close
public final void close() throws javax.jms.JMSExceptionDescription copied from class:AbstractLocalDestinationRelease destination resources- Specified by:
closein classAbstractLocalDestination- Throws:
javax.jms.JMSException
-
getSentToQueueCount
public long getSentToQueueCount()
Description copied from interface:LocalQueueMBeanGet the number of messages sent to this queue (since startup or last reset)- Specified by:
getSentToQueueCountin interfaceLocalQueueMBean
-
getReceivedFromQueueCount
public long getReceivedFromQueueCount()
Description copied from interface:LocalQueueMBeanGet the number of messages received from this queue (since startup or last reset)- Specified by:
getReceivedFromQueueCountin interfaceLocalQueueMBean
-
getAcknowledgedGetCount
public long getAcknowledgedGetCount()
Description copied from interface:LocalQueueMBeanGet the number of acknowledged get operations on this queue (since startup or last reset)- Specified by:
getAcknowledgedGetCountin interfaceLocalQueueMBean
-
getRollbackedGetCount
public long getRollbackedGetCount()
Description copied from interface:LocalQueueMBeanGet the number of rollbacked get operations on this queue (since startup or last reset)- Specified by:
getRollbackedGetCountin interfaceLocalQueueMBean
-
getExpiredCount
public long getExpiredCount()
Description copied from interface:LocalQueueMBeanGet the number of messages that were removed from this queue because they expired (since startup or last reset)- Specified by:
getExpiredCountin interfaceLocalQueueMBean
-
getStoreFullEventsCount
public long getStoreFullEventsCount()
Description copied from interface:LocalQueueMBeanGet the number of times a message could not be stored because the queue store was full- Specified by:
getStoreFullEventsCountin interfaceLocalQueueMBean
-
getLastActivity
public long getLastActivity()
Description copied from interface:ActiveObjectGet a timestamp of this object's last activity- Specified by:
getLastActivityin interfaceActiveObject- Returns:
- a java timestamp
-
getTimeoutDelay
public long getTimeoutDelay()
Description copied from interface:ActiveObjectGet the maximum allowed time between activities- Specified by:
getTimeoutDelayin interfaceActiveObject- Returns:
- a delay in milliseconds
-
onActivityTimeout
public boolean onActivityTimeout() throws ExceptionDescription copied from interface:ActiveObjectCalled if the object has been inactive for more- Specified by:
onActivityTimeoutin interfaceActiveObject- Returns:
- true if the object should be unregistered immediately upon return
- Throws:
Exception
-
processAvailabilityNotificationQueue
protected void processAvailabilityNotificationQueue()
-
hasPendingChanges
protected boolean hasPendingChanges()
Description copied from class:AbstractLocalDestinationTest if this destinations still has some uncommitted changes- Specified by:
hasPendingChangesin classAbstractLocalDestination- Returns:
- true if this destinations still has some uncommitted changes
-
requiresTransactionalUpdate
protected boolean requiresTransactionalUpdate()
Description copied from class:AbstractLocalDestinationTest if this destination requires transactional semantics to be updated- Specified by:
requiresTransactionalUpdatein classAbstractLocalDestination- Returns:
- true if a transaction is required
-
-