001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.activemq.store; 019 020 import javax.jms.JMSException; 021 022 import org.activemq.message.ConsumerInfo; 023 import org.activemq.service.MessageIdentity; 024 import org.activemq.service.SubscriberEntry; 025 026 /** 027 * A MessageStore for durable topic subscriptions 028 * 029 * @version $Revision: 1.1.1.1 $ 030 */ 031 public interface TopicMessageStore extends MessageStore { 032 033 /** 034 * Increments the reference count of the message ID as its been dispatched 035 * to another subscriber. 036 * 037 * @param messageId 038 */ 039 public void incrementMessageCount(MessageIdentity messageId) throws JMSException; 040 041 /** 042 * Decrement the reference count of this message ID and if there 043 * are no more references then delete the message from persistent store 044 * (or maybe archive it off somewhere) 045 * 046 * @param msgId 047 */ 048 public void decrementMessageCountAndMaybeDelete(MessageIdentity msgId) throws JMSException; 049 050 /** 051 * Stores the last acknowledged messgeID for the given subscription 052 * so that we can recover and commence dispatching messages from the last 053 * checkpoint 054 * 055 * @param subscriptionPersistentId 056 * @param messageIdentity 057 */ 058 public void setLastAcknowledgedMessageIdentity(String subscription, MessageIdentity messageIdentity) throws JMSException; 059 060 /** 061 * @param sub 062 * @throws JMSException 063 */ 064 public void deleteSubscription(String subscription) throws JMSException; 065 066 /** 067 * For the new subcription find the last acknowledged message ID 068 * and then find any new messages since then and dispatch them 069 * to the subscription. 070 * <p/> 071 * If this is a new subscription then the lastDispatchMessage should be written to the 072 * acknowledgement table to write a checkpoint so that when we recover we will start 073 * from the correct point. 074 * <p/> 075 * e.g. if we dispatched some messages to a new durable topic subscriber, then went down before 076 * acknowledging any messages, we need to know the correct point from which to recover from. 077 * 078 * @param subscription 079 * @param lastDispatchedMessage 080 */ 081 public void recoverSubscription(String subscriptionId, MessageIdentity lastDispatchedMessage, RecoveryListener listener) throws JMSException; 082 083 /** 084 * Returns the last message identity that was delivered on this container which can then be used as a 085 * checkpoint so that when new durable consumers start, we know where to checkpoint their subscriptions. 086 * <p/> 087 * Note that this method does not need to return a valid messageID, purely the sequence number. 088 * 089 * @return the last message identity which was persisted in the durable store or null if the store is empty. 090 */ 091 public MessageIdentity getLastestMessageIdentity() throws JMSException; 092 093 /** 094 * Finds the subscriber entry for the given consumer info 095 * 096 * @param info 097 * @return 098 */ 099 public SubscriberEntry getSubscriberEntry(ConsumerInfo info) throws JMSException; 100 101 /** 102 * Inserts or updates the subscriber info due to a subscription change 103 * 104 * @param info 105 * @param subscriberEntry 106 * @throws JMSException 107 */ 108 public void setSubscriberEntry(ConsumerInfo info, SubscriberEntry subscriberEntry) throws JMSException; 109 110 }