Source code: org/activemq/store/TopicMessageStore.java
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.activemq.store;
19
20 import javax.jms.JMSException;
21
22 import org.activemq.message.ConsumerInfo;
23 import org.activemq.service.MessageIdentity;
24 import org.activemq.service.SubscriberEntry;
25
26 /**
27 * A MessageStore for durable topic subscriptions
28 *
29 * @version $Revision: 1.1.1.1 $
30 */
31 public interface TopicMessageStore extends MessageStore {
32
33 /**
34 * Increments the reference count of the message ID as its been dispatched
35 * to another subscriber.
36 *
37 * @param messageId
38 */
39 public void incrementMessageCount(MessageIdentity messageId) throws JMSException;
40
41 /**
42 * Decrement the reference count of this message ID and if there
43 * are no more references then delete the message from persistent store
44 * (or maybe archive it off somewhere)
45 *
46 * @param msgId
47 */
48 public void decrementMessageCountAndMaybeDelete(MessageIdentity msgId) throws JMSException;
49
50 /**
51 * Stores the last acknowledged messgeID for the given subscription
52 * so that we can recover and commence dispatching messages from the last
53 * checkpoint
54 *
55 * @param subscriptionPersistentId
56 * @param messageIdentity
57 */
58 public void setLastAcknowledgedMessageIdentity(String subscription, MessageIdentity messageIdentity) throws JMSException;
59
60 /**
61 * @param sub
62 * @throws JMSException
63 */
64 public void deleteSubscription(String subscription) throws JMSException;
65
66 /**
67 * For the new subcription find the last acknowledged message ID
68 * and then find any new messages since then and dispatch them
69 * to the subscription.
70 * <p/>
71 * If this is a new subscription then the lastDispatchMessage should be written to the
72 * acknowledgement table to write a checkpoint so that when we recover we will start
73 * from the correct point.
74 * <p/>
75 * e.g. if we dispatched some messages to a new durable topic subscriber, then went down before
76 * acknowledging any messages, we need to know the correct point from which to recover from.
77 *
78 * @param subscription
79 * @param lastDispatchedMessage
80 */
81 public void recoverSubscription(String subscriptionId, MessageIdentity lastDispatchedMessage, RecoveryListener listener) throws JMSException;
82
83 /**
84 * Returns the last message identity that was delivered on this container which can then be used as a
85 * checkpoint so that when new durable consumers start, we know where to checkpoint their subscriptions.
86 * <p/>
87 * Note that this method does not need to return a valid messageID, purely the sequence number.
88 *
89 * @return the last message identity which was persisted in the durable store or null if the store is empty.
90 */
91 public MessageIdentity getLastestMessageIdentity() throws JMSException;
92
93 /**
94 * Finds the subscriber entry for the given consumer info
95 *
96 * @param info
97 * @return
98 */
99 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 }