Package org.apache.activemq.store.jdbc
Class JDBCMessageStore
- java.lang.Object
-
- org.apache.activemq.store.AbstractMessageStore
-
- org.apache.activemq.store.jdbc.JDBCMessageStore
-
- All Implemented Interfaces:
Service
,MessageStore
- Direct Known Subclasses:
JDBCTopicMessageStore
public class JDBCMessageStore extends AbstractMessageStore
-
-
Field Summary
Fields Modifier and Type Field Description protected JDBCAdapter
adapter
protected ActiveMQMessageAudit
audit
protected LinkedList<Long>
pendingAdditions
protected JDBCPersistenceAdapter
persistenceAdapter
protected TreeMap<Long,Message>
rolledBackAcks
protected WireFormat
wireFormat
-
Fields inherited from class org.apache.activemq.store.AbstractMessageStore
destination, FUTURE, indexListener, messageStoreStatistics, prioritizedMessages
-
-
Constructor Summary
Constructors Constructor Description JDBCMessageStore(JDBCPersistenceAdapter persistenceAdapter, JDBCAdapter adapter, WireFormat wireFormat, ActiveMQDestination destination, ActiveMQMessageAudit audit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMessage(ConnectionContext context, Message message)
Adds a message to the message storevoid
addMessageReference(ConnectionContext context, MessageId messageId, long expirationTime, String messageRef)
Message
getMessage(MessageId messageId)
Looks up a message using either the String messageID or the messageNumber.int
getMessageCount()
String
getMessageReference(MessageId messageId)
protected void
onAdd(Message message, long sequenceId, byte priority)
void
recover(MessageRecoveryListener listener)
Recover any messages to be delivered.void
recoverNextMessages(int maxReturned, MessageRecoveryListener listener)
void
removeAllMessages(ConnectionContext context)
Removes all the messages from the message store.void
removeMessage(ConnectionContext context, MessageAck ack)
Removes a message from the message store.void
resetBatching()
A hint to the Store to reset any batching state for the Destinationvoid
setBatch(MessageId messageId)
allow caching cursors to set the current batch offset when cache is exhaustedvoid
setPrioritizedMessages(boolean prioritizedMessages)
A hint to the store to try recover messages according to priorityString
toString()
void
trackRollbackAck(Message message)
void
updateMessage(Message message)
-
Methods inherited from class org.apache.activemq.store.AbstractMessageStore
addMessage, asyncAddQueueMessage, asyncAddQueueMessage, asyncAddTopicMessage, asyncAddTopicMessage, dispose, getDestination, getIndexListener, getMessageSize, getMessageStoreStatistics, isEmpty, isPrioritizedMessages, recoverMessageStoreStatistics, registerIndexListener, removeAsyncMessage, setMemoryUsage, start, stop
-
-
-
-
Field Detail
-
wireFormat
protected final WireFormat wireFormat
-
adapter
protected final JDBCAdapter adapter
-
persistenceAdapter
protected final JDBCPersistenceAdapter persistenceAdapter
-
audit
protected ActiveMQMessageAudit audit
-
pendingAdditions
protected final LinkedList<Long> pendingAdditions
-
-
Constructor Detail
-
JDBCMessageStore
public JDBCMessageStore(JDBCPersistenceAdapter persistenceAdapter, JDBCAdapter adapter, WireFormat wireFormat, ActiveMQDestination destination, ActiveMQMessageAudit audit) throws IOException
- Throws:
IOException
-
-
Method Detail
-
addMessage
public void addMessage(ConnectionContext context, Message message) throws IOException
Description copied from interface:MessageStore
Adds a message to the message store- Parameters:
context
- context- Throws:
IOException
-
updateMessage
public void updateMessage(Message message) throws IOException
- Specified by:
updateMessage
in interfaceMessageStore
- Overrides:
updateMessage
in classAbstractMessageStore
- Throws:
IOException
-
onAdd
protected void onAdd(Message message, long sequenceId, byte priority)
-
addMessageReference
public void addMessageReference(ConnectionContext context, MessageId messageId, long expirationTime, String messageRef) throws IOException
- Throws:
IOException
-
getMessage
public Message getMessage(MessageId messageId) throws IOException
Description copied from interface:MessageStore
Looks 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:
messageId
- which contains either the messageID or the messageNumber- Returns:
- the message or null if it does not exist
- Throws:
IOException
-
getMessageReference
public String getMessageReference(MessageId messageId) throws IOException
- Throws:
IOException
-
removeMessage
public void removeMessage(ConnectionContext context, MessageAck ack) throws IOException
Description copied from interface:MessageStore
Removes 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
-
recover
public void recover(MessageRecoveryListener listener) throws Exception
Description copied from interface:MessageStore
Recover any messages to be delivered.- Throws:
Exception
-
removeAllMessages
public void removeAllMessages(ConnectionContext context) throws IOException
Description copied from interface:MessageStore
Removes all the messages from the message store.- Throws:
IOException
- See Also:
MessageStore.removeAllMessages(ConnectionContext)
-
getMessageCount
public int getMessageCount() throws IOException
- Specified by:
getMessageCount
in interfaceMessageStore
- Overrides:
getMessageCount
in classAbstractMessageStore
- Returns:
- the number of messages ready to deliver
- Throws:
IOException
-
recoverNextMessages
public void recoverNextMessages(int maxReturned, MessageRecoveryListener listener) throws Exception
- Parameters:
maxReturned
-listener
-- Throws:
Exception
- See Also:
MessageStore.recoverNextMessages(int, org.apache.activemq.store.MessageRecoveryListener)
-
trackRollbackAck
public void trackRollbackAck(Message message)
-
resetBatching
public void resetBatching()
Description copied from interface:MessageStore
A hint to the Store to reset any batching state for the Destination- See Also:
MessageStore.resetBatching()
-
setBatch
public void setBatch(MessageId messageId)
Description copied from interface:MessageStore
allow caching cursors to set the current batch offset when cache is exhausted- Specified by:
setBatch
in interfaceMessageStore
- Overrides:
setBatch
in classAbstractMessageStore
-
setPrioritizedMessages
public void setPrioritizedMessages(boolean prioritizedMessages)
Description copied from interface:MessageStore
A hint to the store to try recover messages according to priority- Specified by:
setPrioritizedMessages
in interfaceMessageStore
- Overrides:
setPrioritizedMessages
in classAbstractMessageStore
-
-