Class AbstractMessageStore
- java.lang.Object
-
- net.timewalker.ffmq4.storage.message.impl.AbstractMessageStore
-
- All Implemented Interfaces:
MessageStore
- Direct Known Subclasses:
BlockFileMessageStore,InMemoryMessageStore
public abstract class AbstractMessageStore extends Object implements MessageStore
AbstractMessageStore
-
-
Field Summary
Fields Modifier and Type Field Description protected LinkedDataStoredataStoreprotected QueueDefinitionqueueDef
-
Constructor Summary
Constructors Constructor Description AbstractMessageStore(QueueDefinition queueDef)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Close the store releasing associated system resourcesvoidcommitChanges()Ensure everything is persisted (synchronous)voidcommitChanges(SynchronizationBarrier barrier)Ensure everything is persisted (asynchronous)protected abstract LinkedDataStorecreateDataStore()voiddelete(int handle)Delete message associated to the given handle from the storeintfirst()Get the first message handle storedintgetAbsoluteStoreUsage()Get the absolute store usage amount (%) (Ratio of used space over maximum allocatable space)intgetStoreUsage()Get the store usage amount (%) (Ratio of used space over currently allocated space)voidinit()Initialize the message storebooleanisLocked(int handle)Check if the message associated with a given handle is lockedvoidlock(int handle)Lock the message associated to a given handleintnext(int handle)Get the next message handle after the given oneintprevious(int handle)Get the previous message handle after the given oneintreplace(int handle, AbstractMessage message)Replace a message in the storeprotected abstract intreplaceMessage(int handle, AbstractMessage message)AbstractMessageretrieve(int handle)Retrieve the message associated to a given handleprotected abstract AbstractMessageretrieveMessage(int handle)Retrieve the message with the given handleprotected abstract intretrieveMessagePriority(int handle)Retrieve the priority of the message with the given handleintsize()Get the number of messages in the storeintstore(AbstractMessage message)Put some message under in the store after the last message with the same priorityprotected abstract intstoreMessage(AbstractMessage message, int previousHandle)Store a message right after the given handleStringtoString()voidunlock(int handle)Unlock the message associated to a given handle-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.timewalker.ffmq4.storage.message.MessageStore
delete, getDeliveryMode, isFailSafe
-
-
-
-
Field Detail
-
queueDef
protected QueueDefinition queueDef
-
dataStore
protected LinkedDataStore dataStore
-
-
Constructor Detail
-
AbstractMessageStore
public AbstractMessageStore(QueueDefinition queueDef)
Constructor
-
-
Method Detail
-
createDataStore
protected abstract LinkedDataStore createDataStore()
-
init
public void init() throws javax.jms.JMSExceptionDescription copied from interface:MessageStoreInitialize the message store- Specified by:
initin interfaceMessageStore- Throws:
javax.jms.JMSException
-
getStoreUsage
public final int getStoreUsage()
Description copied from interface:MessageStoreGet the store usage amount (%) (Ratio of used space over currently allocated space)- Specified by:
getStoreUsagein interfaceMessageStore
-
getAbsoluteStoreUsage
public final int getAbsoluteStoreUsage()
Description copied from interface:MessageStoreGet the absolute store usage amount (%) (Ratio of used space over maximum allocatable space)- Specified by:
getAbsoluteStoreUsagein interfaceMessageStore
-
previous
public final int previous(int handle) throws javax.jms.JMSExceptionDescription copied from interface:MessageStoreGet the previous message handle after the given one- Specified by:
previousin interfaceMessageStore- Parameters:
handle- message handle- Returns:
- the previous entry handle or -1 if their is no successor
- Throws:
javax.jms.JMSException
-
delete
public final void delete(int handle) throws javax.jms.JMSExceptionDescription copied from interface:MessageStoreDelete message associated to the given handle from the store- Specified by:
deletein interfaceMessageStore- Throws:
javax.jms.JMSException- on storage error or invalid handle
-
first
public final int first() throws javax.jms.JMSExceptionDescription copied from interface:MessageStoreGet the first message handle stored- Specified by:
firstin interfaceMessageStore- Returns:
- the first entry handle or -1 if the store is empty
- Throws:
javax.jms.JMSException
-
next
public final int next(int handle) throws javax.jms.JMSExceptionDescription copied from interface:MessageStoreGet the next message handle after the given one- Specified by:
nextin interfaceMessageStore- Parameters:
handle- block handle- Returns:
- the next entry handle or -1 if their is no successor
- Throws:
javax.jms.JMSException
-
size
public final int size()
Description copied from interface:MessageStoreGet the number of messages in the store- Specified by:
sizein interfaceMessageStore
-
commitChanges
public final void commitChanges(SynchronizationBarrier barrier) throws javax.jms.JMSException
Description copied from interface:MessageStoreEnsure everything is persisted (asynchronous)- Specified by:
commitChangesin interfaceMessageStore- Throws:
javax.jms.JMSException
-
commitChanges
public final void commitChanges() throws javax.jms.JMSExceptionDescription copied from interface:MessageStoreEnsure everything is persisted (synchronous)- Specified by:
commitChangesin interfaceMessageStore- Throws:
javax.jms.JMSException
-
close
public final void close()
Description copied from interface:MessageStoreClose the store releasing associated system resources- Specified by:
closein interfaceMessageStore
-
retrieveMessage
protected abstract AbstractMessage retrieveMessage(int handle) throws javax.jms.JMSException
Retrieve the message with the given handle- Throws:
javax.jms.JMSException
-
retrieveMessagePriority
protected abstract int retrieveMessagePriority(int handle) throws javax.jms.JMSExceptionRetrieve the priority of the message with the given handle- Throws:
javax.jms.JMSException
-
storeMessage
protected abstract int storeMessage(AbstractMessage message, int previousHandle) throws javax.jms.JMSException
Store a message right after the given handle- Throws:
javax.jms.JMSException
-
retrieve
public final AbstractMessage retrieve(int handle) throws javax.jms.JMSException
Description copied from interface:MessageStoreRetrieve the message associated to a given handle- Specified by:
retrievein interfaceMessageStore- Throws:
javax.jms.JMSException- on storage error or invalid handle
-
replace
public final int replace(int handle, AbstractMessage message) throws javax.jms.JMSExceptionDescription copied from interface:MessageStoreReplace a message in the store- Specified by:
replacein interfaceMessageStore- Parameters:
handle- message handlemessage- the message to store- Throws:
javax.jms.JMSException
-
replaceMessage
protected abstract int replaceMessage(int handle, AbstractMessage message) throws javax.jms.JMSException- Throws:
javax.jms.JMSException
-
store
public final int store(AbstractMessage message) throws javax.jms.JMSException
Description copied from interface:MessageStorePut some message under in the store after the last message with the same priority- Specified by:
storein interfaceMessageStore- Parameters:
message- the message to store- Throws:
javax.jms.JMSException
-
isLocked
public final boolean isLocked(int handle) throws javax.jms.JMSExceptionDescription copied from interface:MessageStoreCheck if the message associated with a given handle is locked- Specified by:
isLockedin interfaceMessageStore- Throws:
javax.jms.JMSException- on storage error or invalid handle
-
lock
public final void lock(int handle) throws javax.jms.JMSExceptionDescription copied from interface:MessageStoreLock the message associated to a given handle- Specified by:
lockin interfaceMessageStore- Throws:
javax.jms.JMSException- on storage error or invalid handle
-
unlock
public final void unlock(int handle) throws javax.jms.JMSExceptionDescription copied from interface:MessageStoreUnlock the message associated to a given handle- Specified by:
unlockin interfaceMessageStore- Throws:
javax.jms.JMSException- on storage error or invalid handle
-
-