KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > broker > region > cursors > PendingMessageCursor


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

14 package org.apache.activemq.broker.region.cursors;
15
16 import java.io.IOException JavaDoc;
17 import java.util.LinkedList JavaDoc;
18
19 import org.apache.activemq.Service;
20 import org.apache.activemq.broker.ConnectionContext;
21 import org.apache.activemq.broker.region.Destination;
22 import org.apache.activemq.broker.region.MessageReference;
23 import org.apache.activemq.memory.UsageManager;
24
25 /**
26  * Interface to pending message (messages awaiting disptach to a consumer) cursor
27  *
28  * @version $Revision: 500862 $
29  */

30 public interface PendingMessageCursor extends Service{
31     
32     
33     /**
34      * Add a destination
35      * @param context
36      * @param destination
37      * @throws Exception
38      */

39     public void add(ConnectionContext context, Destination destination) throws Exception JavaDoc;
40
41     /**
42      * remove a destination
43      * @param context
44      * @param destination
45      * @throws Exception
46      */

47     public void remove(ConnectionContext context, Destination destination) throws Exception JavaDoc;
48     /**
49      * @return true if there are no pending messages
50      */

51     public boolean isEmpty();
52     
53     /**
54      * check if a Destination is Empty for this cursor
55      * @param destination
56      * @return true id the Destination is empty
57      */

58     public boolean isEmpty(Destination destination);
59     
60     /**
61      * reset the cursor
62      *
63      */

64     public void reset();
65     
66     /**
67      * hint to the cursor to release any locks it might have
68      * grabbed after a reset
69      *
70      */

71     public void release();
72
73     /**
74      * add message to await dispatch
75      * @param node
76      * @throws IOException
77      * @throws Exception
78      */

79     public void addMessageLast(MessageReference node) throws Exception JavaDoc;
80     
81     /**
82      * add message to await dispatch
83      * @param node
84      * @throws Exception
85      */

86     public void addMessageFirst(MessageReference node) throws Exception JavaDoc;
87     
88     /**
89      * Add a message recovered from a retroactive policy
90      * @param node
91      * @throws Exception
92      */

93     public void addRecoveredMessage(MessageReference node) throws Exception JavaDoc;
94
95     /**
96      * @return true if there pending messages to dispatch
97      */

98     public boolean hasNext();
99
100     /**
101      * @return the next pending message
102      */

103     public MessageReference next();
104
105     /**
106      * remove the message at the cursor position
107      *
108      */

109     public void remove();
110
111     /**
112      * @return the number of pending messages
113      */

114     public int size();
115
116     /**
117      * clear all pending messages
118      *
119      */

120     public void clear();
121     
122     /**
123      * Informs the Broker if the subscription needs to intervention to recover it's state
124      * e.g. DurableTopicSubscriber may do
125      * @return true if recovery required
126      */

127     public boolean isRecoveryRequired();
128     
129     /**
130      * @return the maximum batch size
131      */

132     public int getMaxBatchSize();
133
134     /**
135      * Set the max batch size
136      * @param maxBatchSize
137      */

138     public void setMaxBatchSize(int maxBatchSize);
139
140     /**
141      * Give the cursor a hint that we are about to remove
142      * messages from memory only
143      */

144     public void resetForGC();
145     
146     /**
147      * remove a node
148      * @param node
149      */

150     public void remove(MessageReference node);
151     
152     
153     /**
154      * free up any internal buffers
155      *
156      */

157     public void gc();
158     
159     /**
160      * Set the UsageManager
161      * @param usageManager
162      * @see org.apache.activemq.memory.UsageManager
163      */

164     public void setUsageManager(UsageManager usageManager);
165     
166     /**
167      * @return the usageManager
168      */

169     public UsageManager getUsageManager();
170     
171     /**
172      * @return the memoryUsageHighWaterMark
173      */

174     public int getMemoryUsageHighWaterMark();
175
176     
177     /**
178      * @param memoryUsageHighWaterMark the memoryUsageHighWaterMark to set
179      */

180     public void setMemoryUsageHighWaterMark(int memoryUsageHighWaterMark);
181
182     
183     /**
184      * @return true if the cursor is full
185      */

186     public boolean isFull();
187     
188     /**
189      * @return true if the cursor has buffered messages ready to deliver
190      */

191     public boolean hasMessagesBufferedToDeliver();
192     
193     /**
194      * destroy the cursor
195      * @throws Exception
196      */

197     public void destroy() throws Exception JavaDoc;
198     
199     /**
200      * Page in a restricted number of messages
201      * @param maxItems
202      * @return a list of paged in messages
203      */

204     public LinkedList JavaDoc pageInList(int maxItems);
205     
206     
207 }
208
Popular Tags