Class MemoryTopicMessageStore

All Implemented Interfaces:
org.apache.activemq.Service, MessageStore, TopicMessageStore

public class MemoryTopicMessageStore extends MemoryMessageStore implements TopicMessageStore
  • 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

      protected static Map<SubscriptionKey,org.apache.activemq.store.memory.MemoryTopicSub> makeSubMap()
    • addMessage

      public void addMessage(ConnectionContext context, org.apache.activemq.command.Message message) throws IOException
      Description copied from interface: MessageStore
      Adds a message to the message store
      Specified by:
      addMessage in interface MessageStore
      Overrides:
      addMessage in class MemoryMessageStore
      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: TopicMessageStore
      Stores the last acknowledged messgeID for the given subscription so that we can recover and commence dispatching messages from the last checkpoint
      Specified by:
      acknowledge in interface TopicMessageStore
      Throws:
      IOException
    • lookupSubscription

      public org.apache.activemq.command.SubscriptionInfo lookupSubscription(String clientId, String subscriptionName) throws IOException
      Description copied from interface: TopicMessageStore
      Finds the subscriber entry for the given consumer info
      Specified by:
      lookupSubscription in interface TopicMessageStore
      Returns:
      the SubscriptionInfo
      Throws:
      IOException
    • addSubscription

      public void addSubscription(org.apache.activemq.command.SubscriptionInfo info, boolean retroactive) throws IOException
      Description copied from interface: TopicMessageStore
      Inserts 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:
      addSubscription in interface TopicMessageStore
      Throws:
      IOException
    • deleteSubscription

      public void deleteSubscription(String clientId, String subscriptionName)
      Specified by:
      deleteSubscription in interface TopicMessageStore
    • recoverSubscription

      public void recoverSubscription(String clientId, String subscriptionName, MessageRecoveryListener listener) throws Exception
      Description copied from interface: TopicMessageStore
      For 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:
      recoverSubscription in interface TopicMessageStore
      Throws:
      Exception
    • delete

      public void delete()
      Overrides:
      delete in class MemoryMessageStore
    • getAllSubscriptions

      public org.apache.activemq.command.SubscriptionInfo[] getAllSubscriptions() throws IOException
      Description copied from interface: TopicMessageStore
      Lists all the durable subscriptions for a given destination.
      Specified by:
      getAllSubscriptions in interface TopicMessageStore
      Returns:
      an array SubscriptionInfos
      Throws:
      IOException
    • getMessageCount

      public int getMessageCount(String clientId, String subscriberName) throws IOException
      Description copied from interface: TopicMessageStore
      Get the number of messages ready to deliver from the store to a durable subscriber
      Specified by:
      getMessageCount in interface TopicMessageStore
      Returns:
      the outstanding message count
      Throws:
      IOException
    • getMessageSize

      public long getMessageSize(String clientId, String subscriberName) throws IOException
      Description copied from interface: TopicMessageStore
      Get the total size of the messages ready to deliver from the store to the durable subscriber
      Specified by:
      getMessageSize in interface TopicMessageStore
      Returns:
      Throws:
      IOException
    • recoverNextMessages

      public void recoverNextMessages(String clientId, String subscriptionName, int maxReturned, MessageRecoveryListener listener) throws Exception
      Description copied from interface: TopicMessageStore
      For an active subscription - retrieve messages from the store for the subscriber after the lastMessageId messageId

      Specified by:
      recoverNextMessages in interface TopicMessageStore
      Throws:
      Exception
    • resetBatching

      public void resetBatching(String clientId, String subscriptionName)
      Description copied from interface: TopicMessageStore
      A hint to the Store to reset any batching state for a durable subscriber
      Specified by:
      resetBatching in interface TopicMessageStore
    • recoverExpired

      public Map<SubscriptionKey,List<org.apache.activemq.command.Message>> recoverExpired(Set<SubscriptionKey> subs, int max, MessageRecoveryListener listener)
      Description copied from interface: TopicMessageStore
      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. 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:
      recoverExpired in interface TopicMessageStore
      Parameters:
      subs - The subscription keys to check for expired messages
      max - The maximum number of messages to check
      Returns:
      Expired messages for each subscription
    • getMessageStoreSubStatistics

      public MessageStoreSubscriptionStatistics getMessageStoreSubStatistics()
      Description copied from interface: TopicMessageStore
      The subscription metrics contained in this store
      Specified by:
      getMessageStoreSubStatistics in interface TopicMessageStore
      Returns: