Source code: org/activemq/service/Subscription.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
19 package org.activemq.service;
20
21 import org.activemq.broker.BrokerClient;
22 import org.activemq.message.ActiveMQDestination;
23 import org.activemq.message.ActiveMQMessage;
24 import org.activemq.message.ConsumerInfo;
25 import org.activemq.message.MessageAck;
26
27 import javax.jms.JMSException;
28
29
30 /**
31 * A Subscription holds messages to be dispatched to a a Client Consumer
32 *
33 * @version $Revision: 1.1.1.1 $
34 */
35 public interface Subscription {
36
37
38 /**
39 * Set the active consumer info
40 * @param client
41 *
42 * @param info
43 */
44 public void setActiveConsumer(BrokerClient client,ConsumerInfo info);
45
46 /**
47 * Called when the Subscription is discarded
48 *
49 * @throws JMSException
50 */
51 public void clear() throws JMSException;
52
53 /**
54 * Called when an active message consumer has closed.
55 *
56 * @throws JMSException
57 */
58
59 public void reset() throws JMSException;
60
61 /**
62 * @return Returns the clientId.
63 */
64 public String getClientId();
65
66 /**
67 * @return Returns the subscriberName.
68 */
69 public String getSubscriberName();
70
71 /**
72 * @return Returns the destination.
73 */
74 public ActiveMQDestination getDestination();
75
76 /**
77 * @return Returns the selector.
78 */
79 public String getSelector();
80
81 /**
82 * @return Returns true if an active message consumer is associated with this
83 */
84 public boolean isActive();
85
86 /**
87 * set the state of the Subscription
88 *
89 * @param newActive
90 */
91 public void setActive(boolean newActive) throws JMSException;
92
93 /**
94 * @return Returns the consumerNumber.
95 */
96 public int getConsumerNumber();
97
98 /**
99 * @return the consumer Id for the active consumer
100 */
101 public String getConsumerId();
102
103 /**
104 * determines if the Subscription is interested in the message
105 *
106 * @param message
107 * @return
108 * @throws JMSException
109 */
110 public boolean isTarget(ActiveMQMessage message) throws JMSException;
111
112
113 /**
114 * If the Subscription is a target for the message, the subscription will add a reference to
115 * the message and register an interest in the message to the container
116 *
117 * @param container
118 * @param message
119 * @throws JMSException
120 */
121
122 public void addMessage(MessageContainer container, ActiveMQMessage message) throws JMSException;
123
124 /**
125 * Indicates a message has been delivered to a MessageConsumer
126 * which is typically called for topic based subscriptions
127 *
128 * @param ack
129 * @throws JMSException
130 */
131
132 public void messageConsumed(MessageAck ack) throws JMSException;
133
134 /**
135 * Retrieve messages to dispatch
136 *
137 * @return
138 * @throws JMSException
139 */
140
141 public ActiveMQMessage[] getMessagesToDispatch() throws JMSException;
142
143 /**
144 * Indicates if this Subscription has more messages to send to the
145 * Consumer
146 *
147 * @return true if more messages available to dispatch
148 * @throws JMSException
149 */
150 public boolean isReadyToDispatch() throws JMSException;
151
152 /**
153 * Indicates the Subscription it's reached it's pre-fetch limit
154 *
155 * @return true/false
156 * @throws JMSException
157 */
158 public boolean isAtPrefetchLimit() throws JMSException;
159
160
161 /**
162 * Indicates the Consumer is a Durable Subscriber
163 *
164 * @return
165 * @throws JMSException
166 */
167 public boolean isDurableTopic() throws JMSException;
168
169 /**
170 * Indicates the consumer is a browser only
171 *
172 * @return true if a Browser
173 * @throws JMSException
174 */
175 public boolean isBrowser() throws JMSException;
176
177
178 /**
179 * Retreives the messageIdentity of the last message sent to this
180 * Queue based Subscription
181 *
182 * @return the messageId of the last message or null
183 * @throws JMSException
184 */
185 public MessageIdentity getLastMessageIdentity() throws JMSException;
186
187
188 /**
189 * Used for a Queue based Subscription to set the last acknowledged
190 * message ID
191 *
192 * @param messageIdentity
193 * @throws JMSException
194 */
195 public void setLastMessageIdentifier(MessageIdentity messageIdentity) throws JMSException;
196
197
198 public boolean isWildcard();
199
200 /**
201 * Returns the persistent key used to uniquely identify this durable topic subscription
202 *
203 * @return
204 */
205 public String getPersistentKey();
206
207 /**
208 * Checks if this subscription is a duplicate durable subscription of the given consumer info
209 *
210 * @param info
211 * @return true if this subscription is a durable topic subscription and the clientID and consumer
212 * names match
213 */
214 public boolean isSameDurableSubscription(ConsumerInfo info) throws JMSException;
215
216 /**
217 * Lazily creates the persistent entry representation of this subscription
218 */
219 public SubscriberEntry getSubscriptionEntry();
220
221 public boolean isLocalSubscription();
222 }