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