Class JournalMessageStore
- java.lang.Object
-
- org.apache.activemq.store.AbstractMessageStore
-
- org.apache.activemq.store.journal.JournalMessageStore
-
- All Implemented Interfaces:
Service,MessageStore
- Direct Known Subclasses:
JournalTopicMessageStore
public class JournalMessageStore extends AbstractMessageStore
A MessageStore that uses a Journal to store it's messages.
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<org.apache.activeio.journal.RecordLocation>inFlightTxLocationsprotected org.apache.activeio.journal.RecordLocationlastLocationprotected MessageStorelongTermStoreprotected JournalPersistenceAdapterperistenceAdapterprotected JournalTransactionStoretransactionStoreprotected TransactionTemplatetransactionTemplate-
Fields inherited from class org.apache.activemq.store.AbstractMessageStore
destination, FUTURE, indexListener, messageStoreStatistics, prioritizedMessages
-
-
Constructor Summary
Constructors Constructor Description JournalMessageStore(JournalPersistenceAdapter adapter, MessageStore checkpointStore, ActiveMQDestination destination)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMessage(ConnectionContext context, Message message)Not synchronized since the Journal has better throughput if you increase the number of concurrent writes that it is doing.voidaddMessageReference(ConnectionContext context, MessageId messageId, long expirationTime, String messageRef)org.apache.activeio.journal.RecordLocationcheckpoint()org.apache.activeio.journal.RecordLocationcheckpoint(Callback postCheckpointTest)MessageStoregetLongTermMessageStore()MessagegetMessage(MessageId identity)Looks up a message using either the String messageID or the messageNumber.intgetMessageCount()StringgetMessageReference(MessageId identity)longgetMessageSize()voidrecover(MessageRecoveryListener listener)Replays the checkpointStore first as those messages are the oldest ones, then messages are replayed from the transaction log and then the cache is updated.voidrecoverNextMessages(int maxReturned, MessageRecoveryListener listener)voidremoveAllMessages(ConnectionContext context)Removes all the messages from the message store.voidremoveMessage(ConnectionContext context, MessageAck ack)Removes a message from the message store.voidreplayAddMessage(ConnectionContext context, Message message)voidreplayRemoveMessage(ConnectionContext context, MessageAck messageAck)voidresetBatching()A hint to the Store to reset any batching state for the DestinationvoidsetBatch(MessageId messageId)allow caching cursors to set the current batch offset when cache is exhaustedvoidsetMemoryUsage(MemoryUsage memoryUsage)voidstart()voidstop()-
Methods inherited from class org.apache.activemq.store.AbstractMessageStore
addMessage, asyncAddQueueMessage, asyncAddQueueMessage, asyncAddTopicMessage, asyncAddTopicMessage, dispose, getDestination, getIndexListener, getMessageStoreStatistics, isEmpty, isPrioritizedMessages, recoverMessageStoreStatistics, registerIndexListener, removeAsyncMessage, setPrioritizedMessages, updateMessage
-
-
-
-
Field Detail
-
peristenceAdapter
protected final JournalPersistenceAdapter peristenceAdapter
-
transactionStore
protected final JournalTransactionStore transactionStore
-
longTermStore
protected final MessageStore longTermStore
-
transactionTemplate
protected final TransactionTemplate transactionTemplate
-
lastLocation
protected org.apache.activeio.journal.RecordLocation lastLocation
-
inFlightTxLocations
protected Set<org.apache.activeio.journal.RecordLocation> inFlightTxLocations
-
-
Constructor Detail
-
JournalMessageStore
public JournalMessageStore(JournalPersistenceAdapter adapter, MessageStore checkpointStore, ActiveMQDestination destination)
-
-
Method Detail
-
setMemoryUsage
public void setMemoryUsage(MemoryUsage memoryUsage)
- Specified by:
setMemoryUsagein interfaceMessageStore- Overrides:
setMemoryUsagein classAbstractMessageStore- Parameters:
memoryUsage- The SystemUsage that is controlling the destination's memory usage.
-
addMessage
public void addMessage(ConnectionContext context, Message message) throws IOException
Not synchronized since the Journal has better throughput if you increase the number of concurrent writes that it is doing.- Parameters:
context- context- Throws:
IOException
-
replayAddMessage
public void replayAddMessage(ConnectionContext context, Message message)
-
removeMessage
public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException
Description copied from interface:MessageStoreRemoves a message from the message store.ack- the ack request that cause the message to be removed. It conatins the identity which contains the messageID of the message that needs to be removed.- Throws:
IOException
-
replayRemoveMessage
public void replayRemoveMessage(ConnectionContext context, MessageAck messageAck)
-
checkpoint
public org.apache.activeio.journal.RecordLocation checkpoint() throws IOException- Returns:
- Throws:
IOException
-
checkpoint
public org.apache.activeio.journal.RecordLocation checkpoint(Callback postCheckpointTest) throws IOException
- Returns:
- Throws:
IOException
-
getMessage
public Message getMessage(MessageId identity) throws IOException
Description copied from interface:MessageStoreLooks up a message using either the String messageID or the messageNumber. Implementations are encouraged to fill in the missing key if its easy to do so.- Parameters:
identity- which contains either the messageID or the messageNumber- Returns:
- the message or null if it does not exist
- Throws:
IOException
-
recover
public void recover(MessageRecoveryListener listener) throws Exception
Replays the checkpointStore first as those messages are the oldest ones, then messages are replayed from the transaction log and then the cache is updated.- Parameters:
listener-- Throws:
Exception
-
start
public void start() throws Exception- Specified by:
startin interfaceService- Overrides:
startin classAbstractMessageStore- Throws:
Exception
-
stop
public void stop() throws Exception- Specified by:
stopin interfaceService- Overrides:
stopin classAbstractMessageStore- Throws:
Exception
-
getLongTermMessageStore
public MessageStore getLongTermMessageStore()
- Returns:
- Returns the longTermStore.
-
removeAllMessages
public void removeAllMessages(ConnectionContext context) throws IOException
Description copied from interface:MessageStoreRemoves all the messages from the message store.- Throws:
IOException- See Also:
MessageStore.removeAllMessages(ConnectionContext)
-
addMessageReference
public void addMessageReference(ConnectionContext context, MessageId messageId, long expirationTime, String messageRef) throws IOException
- Throws:
IOException
-
getMessageReference
public String getMessageReference(MessageId identity) throws IOException
- Throws:
IOException
-
getMessageCount
public int getMessageCount() throws IOException- Specified by:
getMessageCountin interfaceMessageStore- Overrides:
getMessageCountin classAbstractMessageStore- Returns:
- Throws:
IOException- See Also:
MessageStore.getMessageCount()
-
getMessageSize
public long getMessageSize() throws IOException- Specified by:
getMessageSizein interfaceMessageStore- Overrides:
getMessageSizein classAbstractMessageStore- Returns:
- the size of the messages ready to deliver
- Throws:
IOException
-
recoverNextMessages
public void recoverNextMessages(int maxReturned, MessageRecoveryListener listener) throws Exception- Throws:
Exception
-
resetBatching
public void resetBatching()
Description copied from interface:MessageStoreA hint to the Store to reset any batching state for the Destination
-
setBatch
public void setBatch(MessageId messageId) throws Exception
Description copied from interface:MessageStoreallow caching cursors to set the current batch offset when cache is exhausted- Specified by:
setBatchin interfaceMessageStore- Overrides:
setBatchin classAbstractMessageStore- Throws:
Exception
-
-