KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > region > Subscription


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.broker.region;
19
20 import java.io.IOException JavaDoc;
21
22 import org.apache.activemq.broker.ConnectionContext;
23 import org.apache.activemq.command.ActiveMQDestination;
24 import org.apache.activemq.command.ConsumerInfo;
25 import org.apache.activemq.command.MessageAck;
26 import org.apache.activemq.command.MessageDispatchNotification;
27 import org.apache.activemq.command.MessagePull;
28 import org.apache.activemq.command.Response;
29 import org.apache.activemq.filter.MessageEvaluationContext;
30
31 import javax.jms.InvalidSelectorException JavaDoc;
32 import javax.management.ObjectName JavaDoc;
33
34 /**
35  * @version $Revision: 1.5 $
36  */

37 public interface Subscription extends SubscriptionRecovery {
38
39     /**
40      * Used to add messages that match the subscription.
41      * @param node
42      * @throws InterruptedException
43      * @throws IOException
44      */

45     void add(MessageReference node) throws Exception JavaDoc;
46     
47     /**
48      * Used when client acknowledge receipt of dispatched message.
49      * @param node
50      * @throws IOException
51      * @throws Exception
52      */

53     void acknowledge(ConnectionContext context, final MessageAck ack) throws Exception JavaDoc;
54     
55
56     /**
57      * Allows a consumer to pull a message on demand
58      */

59     Response pullMessage(ConnectionContext context, MessagePull pull) throws Exception JavaDoc;
60
61     /**
62      * Is the subscription interested in the message?
63      * @param node
64      * @param context
65      * @return
66      * @throws IOException
67      */

68     boolean matches(MessageReference node, MessageEvaluationContext context) throws IOException JavaDoc;
69     
70     /**
71      * Is the subscription interested in messages in the destination?
72      * @param context
73      * @return
74      */

75     boolean matches(ActiveMQDestination destination);
76     
77     /**
78      * The subscription will be receiving messages from the destination.
79      * @param context
80      * @param destination
81      * @throws Exception
82      */

83     void add(ConnectionContext context, Destination destination) throws Exception JavaDoc;
84     
85     /**
86      * The subscription will be no longer be receiving messages from the destination.
87      * @param context
88      * @param destination
89      */

90     void remove(ConnectionContext context, Destination destination) throws Exception JavaDoc;
91     
92     /**
93      * The ConsumerInfo object that created the subscription.
94      * @param destination
95      */

96     ConsumerInfo getConsumerInfo();
97
98     /**
99      * The subscription should release as may references as it can to help the garbage collector
100      * reclaim memory.
101      */

102     void gc();
103     
104     /**
105      * Used by a Slave Broker to update dispatch infomation
106      * @param mdn
107      * @throws Exception
108      */

109     void processMessageDispatchNotification(MessageDispatchNotification mdn) throws Exception JavaDoc;
110     
111     /**
112      * @return true if the broker is currently in slave mode
113      */

114     boolean isSlaveBroker();
115     
116     /**
117      * @return number of messages pending delivery
118      */

119     int getPendingQueueSize();
120     
121     /**
122      * @return number of messages dispatched to the client
123      */

124     int getDispatchedQueueSize();
125         
126     /**
127      * @return number of messages dispatched to the client
128      */

129     long getDispatchedCounter();
130     
131     /**
132      * @return number of messages that matched the subscription
133      */

134     long getEnqueueCounter();
135
136     /**
137      * @return number of messages queued by the client
138      */

139     long getDequeueCounter();
140
141     /**
142      * @return the JMS selector on the current subscription
143      */

144     public String JavaDoc getSelector();
145     
146     /**
147      * Attempts to change the current active selector on the subscription.
148      * This operation is not supported for persistent topics.
149      */

150     public void setSelector(String JavaDoc selector) throws InvalidSelectorException JavaDoc, UnsupportedOperationException JavaDoc;
151
152     /**
153      * @return the JMX object name that this subscription was registered as if applicable
154      */

155     public ObjectName JavaDoc getObjectName();
156
157     /**
158      * Set when the subscription is registered in JMX
159      */

160     public void setObjectName(ObjectName JavaDoc objectName);
161     
162     /**
163      * @return true when 60% or more room is left for dispatching messages
164      */

165     public boolean isLowWaterMark();
166     
167     /**
168      * @return true when 10% or less room is left for dispatching messages
169      */

170     public boolean isHighWaterMark();
171     
172     /**
173      * inform the MessageConsumer on the client to change it's prefetch
174      * @param newPrefetch
175      */

176     public void updateConsumerPrefetch(int newPrefetch);
177     
178     /**
179      * optimize message consumer prefetch if the consumer supports it
180      *
181      */

182     public void optimizePrefetch();
183     
184     /**
185      * Called when the subscription is destroyed.
186      */

187     public void destroy();
188
189     /**
190      * @return the prefetch size that is configured for the subscription
191      */

192     int getPrefetchSize();
193     
194     /**
195      * Informs the Broker if the subscription needs to intervention to recover it's state
196      * e.g. DurableTopicSubscriber may do
197      * @see org.apache.activemq.region.cursors.PendingMessageCursor
198      * @return true if recovery required
199      */

200     public boolean isRecoveryRequired();
201
202 }
203
Popular Tags