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.util.List;
020    import java.util.Map;
021    import java.io.IOException;
022    
023    import javax.jms.InvalidSelectorException;
024    import javax.management.openmbean.CompositeData;
025    import javax.management.openmbean.OpenDataException;
026    import javax.management.openmbean.TabularData;
027    import javax.management.ObjectName;
028    import javax.management.MalformedObjectNameException;
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 allocated to this destination
193         */
194        @MBeanInfo("Memory limit, in bytes, used for holding undelivered messages before paging to temporary storage.")
195        long getMemoryLimit();
196    
197        /**
198         * set the amount of memory allocated to this destination
199         * @param limit
200         */
201        void setMemoryLimit(long limit);
202        
203        /**
204         * @return the portion of memory from the broker memory limit for this destination
205         */
206        @MBeanInfo("Portion of memory from the broker memory limit for this destination")
207        float getMemoryUsagePortion();
208        
209        /**
210         * set the portion of memory from the broker memory limit for this destination
211         * @param value
212         */
213        void setMemoryUsagePortion(@MBeanInfo("bytes") float value);
214    
215        /**
216         * Browses the current destination returning a list of messages
217         */
218        @MBeanInfo("A list of all messages in the destination. Not HTML friendly.")
219        List<?> browseMessages() throws InvalidSelectorException;
220    
221        /**
222         * Browses the current destination with the given selector returning a list
223         * of messages
224         */
225        @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.")
226        List<?> browseMessages(String selector) throws InvalidSelectorException;
227    
228        /**
229         * @return longest time a message is held by a destination
230         */
231        @MBeanInfo("The longest time a message has been held this destination.")
232        long getMaxEnqueueTime();
233    
234        /**
235         * @return shortest time a message is held by a destination
236         */
237        @MBeanInfo("The shortest time a message has been held this destination.")
238        long getMinEnqueueTime();
239    
240        /**
241         * @return average time a message is held by a destination
242         */
243        @MBeanInfo("Average time a message has been held this destination.")
244        double getAverageEnqueueTime();
245        
246        /**
247         * @return the producerFlowControl
248         */
249        @MBeanInfo("Producers are flow controlled")
250        boolean isProducerFlowControl();
251        
252        /**
253         * @param producerFlowControl the producerFlowControl to set
254         */
255        public void setProducerFlowControl(@MBeanInfo("producerFlowControl") boolean producerFlowControl);
256        
257        /**
258         * Set's the interval at which warnings about producers being blocked by
259         * resource usage will be triggered. Values of 0 or less will disable
260         * warnings
261         * 
262         * @param blockedProducerWarningInterval the interval at which warning about
263         *            blocked producers will be triggered.
264         */
265        public void setBlockedProducerWarningInterval(@MBeanInfo("blockedProducerWarningInterval")  long blockedProducerWarningInterval);
266    
267        /**
268         * 
269         * @return the interval at which warning about blocked producers will be
270         *         triggered.
271         */
272        @MBeanInfo("Blocked Producer Warning Interval")
273        public long getBlockedProducerWarningInterval();
274        
275        /**
276         * @return the maxProducersToAudit
277         */
278        @MBeanInfo("Maximum number of producers to audit") 
279        public int getMaxProducersToAudit();
280        
281        /**
282         * @param maxProducersToAudit the maxProducersToAudit to set
283         */
284        public void setMaxProducersToAudit(@MBeanInfo("maxProducersToAudit") int maxProducersToAudit);
285        
286        /**
287         * @return the maxAuditDepth
288         */
289        @MBeanInfo("Max audit depth")
290        public int getMaxAuditDepth();
291        
292        /**
293         * @param maxAuditDepth the maxAuditDepth to set
294         */
295        public void setMaxAuditDepth(@MBeanInfo("maxAuditDepth") int maxAuditDepth);
296        
297        /**
298         * @return the maximum number of message to be paged into the 
299         * destination
300         */
301        @MBeanInfo("Maximum number of messages to be paged in")
302        public int getMaxPageSize();
303        
304        /**
305         * @param pageSize
306         * Set the maximum number of messages to page into the destination
307         */
308        public void setMaxPageSize(@MBeanInfo("pageSize") int pageSize);
309        
310        /**
311         * @return true if caching is enabled of for the destination
312         */
313        @MBeanInfo("Caching is enabled")
314        public boolean isUseCache();
315        
316        /**
317         * @param value
318         * enable/disable caching on the destination
319         */
320        public void setUseCache(@MBeanInfo("cache") boolean value);
321    
322        /**
323         * Returns all the current subscription MBeans matching this destination
324         * 
325         * @return the names of the subscriptions for this destination
326         */
327        @MBeanInfo("returns all the current subscription MBeans matching this destination")
328        ObjectName[] getSubscriptions() throws IOException, MalformedObjectNameException;
329    
330    }