001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  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    package org.apache.activemq.broker.jmx;
018    
019    import java.io.IOException;
020    import java.util.List;
021    import java.util.Map;
022    import javax.jms.InvalidSelectorException;
023    import javax.management.MalformedObjectNameException;
024    import javax.management.ObjectName;
025    import javax.management.openmbean.CompositeData;
026    import javax.management.openmbean.OpenDataException;
027    import javax.management.openmbean.TabularData;
028    
029    public interface DestinationViewMBean {
030    
031        /**
032         * Returns the name of this destination
033         */
034        @MBeanInfo("Name of this destination.")
035        String getName();
036    
037        /**
038         * Resets the managment counters.
039         */
040        @MBeanInfo("Resets statistics.")
041        void resetStatistics();
042    
043        /**
044         * Returns the number of messages that have been sent to the destination.
045         * 
046         * @return The number of messages that have been sent to the destination.
047         */
048        @MBeanInfo("Number of messages that have been sent to the destination.")
049        long getEnqueueCount();
050    
051        /**
052         * Returns the number of messages that have been delivered (potentially not
053         * acknowledged) to consumers.
054         * 
055         * @return The number of messages that have been delivered (potentially not
056         *         acknowledged) to consumers.
057         */
058        @MBeanInfo("Number of messages that have been delivered (but potentially not acknowledged) to consumers.")
059        long getDispatchCount();
060    
061        /**
062         * Returns the number of messages that have been acknowledged from the
063         * destination.
064         * 
065         * @return The number of messages that have been acknowledged from the
066         *         destination.
067         */
068        @MBeanInfo("Number of messages that have been acknowledged (and removed from) from the destination.")
069        long getDequeueCount();
070        
071        /**
072         * Returns the number of messages that have been dispatched but not
073         * acknowledged
074         * 
075         * @return The number of messages that have been dispatched but not
076         * acknowledged
077         */
078        @MBeanInfo("Number of messages that have been dispatched to, but not acknowledged by, consumers.")
079        long getInFlightCount();
080    
081        /**
082         * Returns the number of messages that have expired
083         * 
084         * @return The number of messages that have expired
085         */
086        @MBeanInfo("Number of messages that have been expired.")
087        long getExpiredCount();
088        
089        /**
090         * Returns the number of consumers subscribed this destination.
091         * 
092         * @return The number of consumers subscribed this destination.
093         */
094        @MBeanInfo("Number of consumers subscribed to this destination.")
095        long getConsumerCount();
096        
097        /**
098         * @return the number of producers publishing to the destination
099         */
100        @MBeanInfo("Number of producers publishing to this destination")
101        long getProducerCount();
102    
103        /**
104         * Returns the number of messages in this destination which are yet to be
105         * consumed
106         * 
107         * @return Returns the number of messages in this destination which are yet
108         *         to be consumed
109         */
110        @MBeanInfo("Number of messages in the destination which are yet to be consumed.  Potentially dispatched but unacknowledged.")
111        long getQueueSize();
112    
113        /**
114         * @return An array of all the messages in the destination's queue.
115         */
116        @MBeanInfo("An array of all messages in the destination. Not HTML friendly.")
117        CompositeData[] browse() throws OpenDataException;
118    
119        /**
120         * @return A list of all the messages in the destination's queue.
121         */
122        @MBeanInfo("A list of all messages in the destination. Not HTML friendly.")
123        TabularData browseAsTable() throws OpenDataException;
124    
125        /**
126         * @return An array of all the messages in the destination's queue.
127         * @throws InvalidSelectorException
128         */
129        @MBeanInfo("An array of all messages in the destination based on an SQL-92 selection on the message headers or XPATH on the body. Not HTML friendly.")
130        CompositeData[] browse(@MBeanInfo("selector") String selector) throws OpenDataException, InvalidSelectorException;
131    
132        /**
133         * @return A list of all the messages in the destination's queue.
134         * @throws InvalidSelectorException
135         */
136        @MBeanInfo("A list of all messages in the destination based on an SQL-92 selection on the message headers or XPATH on the body. Not HTML friendly.")
137        TabularData browseAsTable(@MBeanInfo("selector") String selector) throws OpenDataException, InvalidSelectorException;
138    
139        /**
140         * Sends a TextMesage to the destination.
141         * 
142         * @param body the text to send
143         * @return the message id of the message sent.
144         * @throws Exception
145         */
146        @MBeanInfo("Sends a TextMessage to the destination.")
147        String sendTextMessage(@MBeanInfo("body") String body) throws Exception;
148    
149        /**
150         * Sends a TextMesage to the destination.
151         * 
152         * @param headers the message headers and properties to set. Can only
153         *                container Strings maped to primitive types.
154         * @param body the text to send
155         * @return the message id of the message sent.
156         * @throws Exception
157         */
158        @MBeanInfo("Sends a TextMessage to the destination.")
159        String sendTextMessage(@MBeanInfo("headers") Map<?,?> headers, @MBeanInfo("body") String body) throws Exception;
160    
161        /**
162         * Sends a TextMesage to the destination.
163         * @param body the text to send
164         * @param user
165         * @param password
166         * @return
167         * @throws Exception
168         */
169        @MBeanInfo("Sends a TextMessage to a password-protected destination.")
170        String sendTextMessage(@MBeanInfo("body") String body, @MBeanInfo("user") String user, @MBeanInfo("password") String password) throws Exception;
171        
172        /**
173         * 
174         * @param headers the message headers and properties to set. Can only
175         *                container Strings maped to primitive types.
176         * @param body the text to send
177         * @param user
178         * @param password
179         * @return
180         * @throws Exception
181         */
182        @MBeanInfo("Sends a TextMessage to a password-protected destination.")
183        String sendTextMessage(@MBeanInfo("headers") Map<?,?> headers, @MBeanInfo("body") String body, @MBeanInfo("user") String user, @MBeanInfo("password") String password) throws Exception;
184        /**
185         * @return the percentage of amount of memory used
186         */
187        @MBeanInfo("The percentage of the memory limit used")
188        int getMemoryPercentUsage();
189    
190        /**
191         * @return the amount of memory allocated to this destination
192         */
193        @MBeanInfo("Memory limit, in bytes, used for holding undelivered messages before paging to temporary storage.")
194        long getMemoryLimit();
195    
196        /**
197         * set the amount of memory allocated to this destination
198         * @param limit
199         */
200        void setMemoryLimit(long limit);
201        
202        /**
203         * @return the portion of memory from the broker memory limit for this destination
204         */
205        @MBeanInfo("Portion of memory from the broker memory limit for this destination")
206        float getMemoryUsagePortion();
207        
208        /**
209         * set the portion of memory from the broker memory limit for this destination
210         * @param value
211         */
212        void setMemoryUsagePortion(@MBeanInfo("bytes") float value);
213    
214        /**
215         * Browses the current destination returning a list of messages
216         */
217        @MBeanInfo("A list of all messages in the destination. Not HTML friendly.")
218        List<?> browseMessages() throws InvalidSelectorException;
219    
220        /**
221         * Browses the current destination with the given selector returning a list
222         * of messages
223         */
224        @MBeanInfo("A list of all messages in the destination based on an SQL-92 selection on the message headers or XPATH on the body. Not HTML friendly.")
225        List<?> browseMessages(String selector) throws InvalidSelectorException;
226    
227        /**
228         * @return longest time a message is held by a destination
229         */
230        @MBeanInfo("The longest time a message has been held this destination.")
231        long getMaxEnqueueTime();
232    
233        /**
234         * @return shortest time a message is held by a destination
235         */
236        @MBeanInfo("The shortest time a message has been held this destination.")
237        long getMinEnqueueTime();
238    
239        /**
240         * @return average time a message is held by a destination
241         */
242        @MBeanInfo("Average time a message has been held this destination.")
243        double getAverageEnqueueTime();
244        
245        /**
246         * @return the producerFlowControl
247         */
248        @MBeanInfo("Producers are flow controlled")
249        boolean isProducerFlowControl();
250        
251        /**
252         * @param producerFlowControl the producerFlowControl to set
253         */
254        public void setProducerFlowControl(@MBeanInfo("producerFlowControl") boolean producerFlowControl);
255        
256        /**
257         * @return if we treat consumers as alwaysRetroactive
258         */
259        @MBeanInfo("Always treat consumers as retroActive")
260        boolean isAlwaysRetroactive();
261        
262        /**
263         * @param alwaysRetroactive set as always retroActive
264         */
265        public void setAlwaysRetroactive(@MBeanInfo("alwaysRetroactive") boolean alwaysRetroactive);    
266        
267        /**
268         * Set's the interval at which warnings about producers being blocked by
269         * resource usage will be triggered. Values of 0 or less will disable
270         * warnings
271         * 
272         * @param blockedProducerWarningInterval the interval at which warning about
273         *            blocked producers will be triggered.
274         */
275        public void setBlockedProducerWarningInterval(@MBeanInfo("blockedProducerWarningInterval")  long blockedProducerWarningInterval);
276    
277        /**
278         * 
279         * @return the interval at which warning about blocked producers will be
280         *         triggered.
281         */
282        @MBeanInfo("Blocked Producer Warning Interval")
283        public long getBlockedProducerWarningInterval();
284        
285        /**
286         * @return the maxProducersToAudit
287         */
288        @MBeanInfo("Maximum number of producers to audit") 
289        public int getMaxProducersToAudit();
290        
291        /**
292         * @param maxProducersToAudit the maxProducersToAudit to set
293         */
294        public void setMaxProducersToAudit(@MBeanInfo("maxProducersToAudit") int maxProducersToAudit);
295        
296        /**
297         * @return the maxAuditDepth
298         */
299        @MBeanInfo("Max audit depth")
300        public int getMaxAuditDepth();
301        
302        /**
303         * @param maxAuditDepth the maxAuditDepth to set
304         */
305        public void setMaxAuditDepth(@MBeanInfo("maxAuditDepth") int maxAuditDepth);
306        
307        /**
308         * @return the maximum number of message to be paged into the 
309         * destination
310         */
311        @MBeanInfo("Maximum number of messages to be paged in")
312        public int getMaxPageSize();
313        
314        /**
315         * @param pageSize
316         * Set the maximum number of messages to page into the destination
317         */
318        public void setMaxPageSize(@MBeanInfo("pageSize") int pageSize);
319        
320        /**
321         * @return true if caching is allowed of for the destination
322         */
323        @MBeanInfo("Caching is allowed")
324        public boolean isUseCache();
325        
326        /**
327         * @return true if prioritized messages are enabled for the destination
328         */
329        @MBeanInfo("Prioritized messages is enabled")
330        public boolean isPrioritizedMessages();
331        
332        /**
333         * @param value
334         * enable/disable caching on the destination
335         */
336        public void setUseCache(@MBeanInfo("cache") boolean value);
337    
338        /**
339         * Returns all the current subscription MBeans matching this destination
340         * 
341         * @return the names of the subscriptions for this destination
342         */
343        @MBeanInfo("returns all the current subscription MBeans matching this destination")
344        ObjectName[] getSubscriptions() throws IOException, MalformedObjectNameException;
345    
346    
347        /**
348         * Returns the slow consumer strategy MBean for this destination
349         *
350         * @return the name of the slow consumer handler MBean for this destination
351         */
352        @MBeanInfo("returns the optional slowConsumer handler MBeans for this destination")
353        ObjectName getSlowConsumerStrategy() throws IOException, MalformedObjectNameException;
354    
355    }