Package org.apache.activemq.store.memory
Class MemoryTopicMessageStore
java.lang.Object
org.apache.activemq.store.AbstractMessageStore
org.apache.activemq.store.memory.MemoryMessageStore
org.apache.activemq.store.memory.MemoryTopicMessageStore
- All Implemented Interfaces:
org.apache.activemq.Service,MessageStore,TopicMessageStore
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.activemq.store.MessageStore
MessageStore.StoreType -
Field Summary
Fields inherited from class org.apache.activemq.store.memory.MemoryMessageStore
lastBatchId, messageTable, sequenceIdFields inherited from class org.apache.activemq.store.AbstractMessageStore
destination, FUTURE, indexListener, messageStoreStatistics, prioritizedMessages -
Constructor Summary
ConstructorsConstructorDescriptionMemoryTopicMessageStore(org.apache.activemq.command.ActiveMQDestination destination) MemoryTopicMessageStore(org.apache.activemq.command.ActiveMQDestination destination, Map<org.apache.activemq.command.MessageId, org.apache.activemq.command.Message> messageTable, Map<SubscriptionKey, org.apache.activemq.command.SubscriptionInfo> subscriberDatabase) -
Method Summary
Modifier and TypeMethodDescriptionvoidacknowledge(ConnectionContext context, String clientId, String subscriptionName, org.apache.activemq.command.MessageId messageId, org.apache.activemq.command.MessageAck ack) Stores the last acknowledged messgeID for the given subscription so that we can recover and commence dispatching messages from the last checkpointvoidaddMessage(ConnectionContext context, org.apache.activemq.command.Message message) Adds a message to the message storevoidaddSubscription(org.apache.activemq.command.SubscriptionInfo info, boolean retroactive) Inserts the subscriber info due to a subscription changevoiddelete()voiddeleteSubscription(String clientId, String subscriptionName) org.apache.activemq.command.SubscriptionInfo[]Lists all the durable subscriptions for a given destination.intgetMessageCount(String clientId, String subscriberName) Get the number of messages ready to deliver from the store to a durable subscriberlonggetMessageSize(String clientId, String subscriberName) Get the total size of the messages ready to deliver from the store to the durable subscriberThe subscription metrics contained in this storeorg.apache.activemq.command.SubscriptionInfolookupSubscription(String clientId, String subscriptionName) Finds the subscriber entry for the given consumer infoprotected static Map<SubscriptionKey,org.apache.activemq.store.memory.MemoryTopicSub> protected static Map<SubscriptionKey,org.apache.activemq.command.SubscriptionInfo> Map<SubscriptionKey,List<org.apache.activemq.command.Message>> recoverExpired(Set<SubscriptionKey> subs, int max, MessageRecoveryListener listener) Iterates over the pending messages in a topic and recovers any expired messages found for each of the subscriptions up to the maximum number of messages to search.voidrecoverNextMessages(String clientId, String subscriptionName, int maxReturned, MessageRecoveryListener listener) For an active subscription - retrieve messages from the store for the subscriber after the lastMessageId messageIdvoidrecoverSubscription(String clientId, String subscriptionName, MessageRecoveryListener listener) For the new subscription find the last acknowledged message ID and then find any new messages since then and dispatch them to the subscription.voidresetBatching(String clientId, String subscriptionName) A hint to the Store to reset any batching state for a durable subscriberMethods inherited from class org.apache.activemq.store.memory.MemoryMessageStore
decMessageStoreStatistics, getMessage, getType, incMessageStoreStatistics, recover, recoverMessageStoreStatistics, recoverNextMessages, removeAllMessages, removeMessage, removeMessage, resetBatching, setBatch, updateMessageMethods inherited from class org.apache.activemq.store.AbstractMessageStore
addMessage, asyncAddQueueMessage, asyncAddQueueMessage, asyncAddTopicMessage, asyncAddTopicMessage, dispose, getDestination, getIndexListener, getMessageCount, getMessageSize, getMessageStoreStatistics, isEmpty, isPrioritizedMessages, registerIndexListener, removeAsyncMessage, setMemoryUsage, setPrioritizedMessages, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.activemq.store.MessageStore
addMessage, asyncAddQueueMessage, asyncAddQueueMessage, asyncAddTopicMessage, asyncAddTopicMessage, dispose, getDestination, getMessage, getMessageCount, getMessageSize, getMessageStoreStatistics, getType, isEmpty, isPrioritizedMessages, recover, recoverMessages, recoverNextMessages, registerIndexListener, removeAllMessages, removeAsyncMessage, removeMessage, resetBatching, setBatch, setMemoryUsage, setPrioritizedMessages, updateMessageMethods inherited from interface org.apache.activemq.Service
start, stop
-
Constructor Details
-
MemoryTopicMessageStore
public MemoryTopicMessageStore(org.apache.activemq.command.ActiveMQDestination destination) -
MemoryTopicMessageStore
public MemoryTopicMessageStore(org.apache.activemq.command.ActiveMQDestination destination, Map<org.apache.activemq.command.MessageId, org.apache.activemq.command.Message> messageTable, Map<SubscriptionKey, org.apache.activemq.command.SubscriptionInfo> subscriberDatabase)
-
-
Method Details
-
makeSubscriptionInfoMap
protected static Map<SubscriptionKey,org.apache.activemq.command.SubscriptionInfo> makeSubscriptionInfoMap() -
makeSubMap
-
addMessage
public void addMessage(ConnectionContext context, org.apache.activemq.command.Message message) throws IOException Description copied from interface:MessageStoreAdds a message to the message store- Specified by:
addMessagein interfaceMessageStore- Overrides:
addMessagein classMemoryMessageStore- Parameters:
context- context- Throws:
IOException
-
acknowledge
public void acknowledge(ConnectionContext context, String clientId, String subscriptionName, org.apache.activemq.command.MessageId messageId, org.apache.activemq.command.MessageAck ack) throws IOException Description copied from interface:TopicMessageStoreStores the last acknowledged messgeID for the given subscription so that we can recover and commence dispatching messages from the last checkpoint- Specified by:
acknowledgein interfaceTopicMessageStore- Throws:
IOException
-
lookupSubscription
public org.apache.activemq.command.SubscriptionInfo lookupSubscription(String clientId, String subscriptionName) throws IOException Description copied from interface:TopicMessageStoreFinds the subscriber entry for the given consumer info- Specified by:
lookupSubscriptionin interfaceTopicMessageStore- Returns:
- the SubscriptionInfo
- Throws:
IOException
-
addSubscription
public void addSubscription(org.apache.activemq.command.SubscriptionInfo info, boolean retroactive) throws IOException Description copied from interface:TopicMessageStoreInserts the subscriber info due to a subscription change If this is a new subscription and the retroactive is false, then the last message sent to the topic should be set as the last message acknowledged by they new subscription. Otherwise, if retroactive is true, then create the subscription without it having an acknowledged message so that on recovery, all message recorded for the topic get replayed.- Specified by:
addSubscriptionin interfaceTopicMessageStore- Throws:
IOException
-
deleteSubscription
- Specified by:
deleteSubscriptionin interfaceTopicMessageStore
-
recoverSubscription
public void recoverSubscription(String clientId, String subscriptionName, MessageRecoveryListener listener) throws Exception Description copied from interface:TopicMessageStoreFor the new subscription find the last acknowledged message ID and then find any new messages since then and dispatch them to the subscription. e.g. if we dispatched some messages to a new durable topic subscriber, then went down before acknowledging any messages, we need to know the correct point from which to recover from.- Specified by:
recoverSubscriptionin interfaceTopicMessageStore- Throws:
Exception
-
delete
public void delete()- Overrides:
deletein classMemoryMessageStore
-
getAllSubscriptions
Description copied from interface:TopicMessageStoreLists all the durable subscriptions for a given destination.- Specified by:
getAllSubscriptionsin interfaceTopicMessageStore- Returns:
- an array SubscriptionInfos
- Throws:
IOException
-
getMessageCount
Description copied from interface:TopicMessageStoreGet the number of messages ready to deliver from the store to a durable subscriber- Specified by:
getMessageCountin interfaceTopicMessageStore- Returns:
- the outstanding message count
- Throws:
IOException
-
getMessageSize
Description copied from interface:TopicMessageStoreGet the total size of the messages ready to deliver from the store to the durable subscriber- Specified by:
getMessageSizein interfaceTopicMessageStore- Returns:
- Throws:
IOException
-
recoverNextMessages
public void recoverNextMessages(String clientId, String subscriptionName, int maxReturned, MessageRecoveryListener listener) throws Exception Description copied from interface:TopicMessageStoreFor an active subscription - retrieve messages from the store for the subscriber after the lastMessageId messageId- Specified by:
recoverNextMessagesin interfaceTopicMessageStore- Throws:
Exception
-
resetBatching
Description copied from interface:TopicMessageStoreA hint to the Store to reset any batching state for a durable subscriber- Specified by:
resetBatchingin interfaceTopicMessageStore
-
recoverExpired
public Map<SubscriptionKey,List<org.apache.activemq.command.Message>> recoverExpired(Set<SubscriptionKey> subs, int max, MessageRecoveryListener listener) Description copied from interface:TopicMessageStoreIterates over the pending messages in a topic and recovers any expired messages found for each of the subscriptions up to the maximum number of messages to search. Only subscriptions that have at least 1 expired message will be returned in the map.
The expiry listener is only used to verify if there is space. Messages that are expired and will be added to 1 or more subscription in the returned map will be passed to the callback. The callback will only be called once per each unique message.- Specified by:
recoverExpiredin interfaceTopicMessageStore- Parameters:
subs- The subscription keys to check for expired messagesmax- The maximum number of messages to check- Returns:
- Expired messages for each subscription
-
getMessageStoreSubStatistics
Description copied from interface:TopicMessageStoreThe subscription metrics contained in this store- Specified by:
getMessageStoreSubStatisticsin interfaceTopicMessageStore- Returns:
-