View Javadoc

    1   /***
    2    *
    3    * Copyright 2004 Protique Ltd
    4    *
    5    * Licensed under the Apache License, Version 2.0 (the "License");
    6    * you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    *
    9    * http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   *
    17   **/
    18  package org.codehaus.activemq.store;
    19
    20  import org.codehaus.activemq.message.ConsumerInfo;
    21  import org.codehaus.activemq.message.MessageAck;
    22  import org.codehaus.activemq.service.MessageContainer;
    23  import org.codehaus.activemq.service.MessageIdentity;
    24  import org.codehaus.activemq.service.SubscriberEntry;
    25  import org.codehaus.activemq.service.Subscription;
    26
    27  import javax.jms.JMSException;
    28
    29  /***
    30   * A MessageStore for durable topic subscriptions
    31   *
    32   * @version $Revision: 1.1 $
    33   */
    34  public interface TopicMessageStore extends MessageStore {
    35
    36      /***
    37       * Called before the service is started so that the store can communicate with
    38       * the container when recovering
    39       *
    40       * @param container
    41       */
    42      public void setMessageContainer(MessageContainer container);
    43
    44      /***
    45       * Increments the reference count of the message ID as its been dispatched
    46       * to another subscriber.
    47       *
    48       * @param messageId
    49       */
    50      public void incrementMessageCount(MessageIdentity messageId) throws JMSException;
    51
    52      /***
    53       * Decrement the reference count of this message ID and if there
    54       * are no more references then delete the message from persistent store
    55       * (or maybe archive it off somewhere)
    56       *
    57       * @param messageIdentity
    58       * @param ack
    59       */
    60      public void decrementMessageCountAndMaybeDelete(MessageIdentity messageIdentity, MessageAck ack) throws JMSException;
    61
    62      /***
    63       * Stores the last acknowledged messgeID for the given subscription
    64       * so that we can recover and commence dispatching messages from the last
    65       * checkpoint
    66       *
    67       * @param subscription
    68       * @param messageIdentity
    69       */
    70      public void setLastAcknowledgedMessageIdentity(Subscription subscription, MessageIdentity messageIdentity) throws JMSException;
    71
    72      /***
    73       * For the new subcription find the last acknowledged message ID
    74       * and then find any new messages since then and dispatch them
    75       * to the subscription.
    76       * <p/>
    77       * If this is a new subscription then the lastDispatchMessage should be written to the
    78       * acknowledgement table to write a checkpoint so that when we recover we will start
    79       * from the correct point.
    80       * <p/>
    81       * e.g. if we dispatched some messages to a new durable topic subscriber, then went down before
    82       * acknowledging any messages, we need to know the correct point from which to recover from.
    83       *
    84       * @param subscription
    85       * @param lastDispatchedMessage
    86       */
    87      public void recoverSubscription(Subscription subscription, MessageIdentity lastDispatchedMessage) throws JMSException;
    88
    89      /***
    90       * Returns the last message identity that was delivered on this container which can then be used as a
    91       * checkpoint so that when new durable consumers start, we know where to checkpoint their subscriptions.
    92       * <p/>
    93       * Note that this method does not need to return a valid messageID, purely the sequence number.
    94       *
    95       * @return the last message identity which was persisted in the durable store or null if the store is empty.
    96       */
    97      public MessageIdentity getLastestMessageIdentity() throws JMSException;
    98
    99      /***
    100      * Finds the subscriber entry for the given consumer info
    101      *
    102      * @param info
    103      * @return
    104      */
    105     public SubscriberEntry getSubscriberEntry(ConsumerInfo info) throws JMSException;
    106
    107     /***
    108      * Inserts or updates the subscriber info due to a subscription change
    109      *
    110      * @param info
    111      * @param subscriberEntry
    112      * @throws JMSException
    113      */
    114     public void setSubscriberEntry(ConsumerInfo info, SubscriberEntry subscriberEntry) throws JMSException;
    115 }