Class MemoryTopicMessageStore

    • Constructor Detail

      • 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 Detail

      • makeSubscriptionInfoMap

        protected static Map<SubscriptionKey,​org.apache.activemq.command.SubscriptionInfo> makeSubscriptionInfoMap()
      • makeSubMap

        protected static Map<SubscriptionKey,​org.apache.activemq.store.memory.MemoryTopicSub> makeSubMap()
      • 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
      • 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
      • 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
      • 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