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 */
017package org.apache.activemq.broker.jmx;
018
019import java.io.IOException;
020import java.util.List;
021import java.util.Map;
022import javax.jms.InvalidSelectorException;
023import javax.management.MalformedObjectNameException;
024import javax.management.ObjectName;
025import javax.management.openmbean.CompositeData;
026import javax.management.openmbean.OpenDataException;
027import javax.management.openmbean.TabularData;
028
029public 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     * Set's the interval at which warnings about producers being blocked by
258     * resource usage will be triggered. Values of 0 or less will disable
259     * warnings
260     * 
261     * @param blockedProducerWarningInterval the interval at which warning about
262     *            blocked producers will be triggered.
263     */
264    public void setBlockedProducerWarningInterval(@MBeanInfo("blockedProducerWarningInterval")  long blockedProducerWarningInterval);
265
266    /**
267     * 
268     * @return the interval at which warning about blocked producers will be
269     *         triggered.
270     */
271    @MBeanInfo("Blocked Producer Warning Interval")
272    public long getBlockedProducerWarningInterval();
273    
274    /**
275     * @return the maxProducersToAudit
276     */
277    @MBeanInfo("Maximum number of producers to audit") 
278    public int getMaxProducersToAudit();
279    
280    /**
281     * @param maxProducersToAudit the maxProducersToAudit to set
282     */
283    public void setMaxProducersToAudit(@MBeanInfo("maxProducersToAudit") int maxProducersToAudit);
284    
285    /**
286     * @return the maxAuditDepth
287     */
288    @MBeanInfo("Max audit depth")
289    public int getMaxAuditDepth();
290    
291    /**
292     * @param maxAuditDepth the maxAuditDepth to set
293     */
294    public void setMaxAuditDepth(@MBeanInfo("maxAuditDepth") int maxAuditDepth);
295    
296    /**
297     * @return the maximum number of message to be paged into the 
298     * destination
299     */
300    @MBeanInfo("Maximum number of messages to be paged in")
301    public int getMaxPageSize();
302    
303    /**
304     * @param pageSize
305     * Set the maximum number of messages to page into the destination
306     */
307    public void setMaxPageSize(@MBeanInfo("pageSize") int pageSize);
308    
309    /**
310     * @return true if caching is allowed of for the destination
311     */
312    @MBeanInfo("Caching is allowed")
313    public boolean isUseCache();
314    
315    /**
316     * @return true if prioritized messages are enabled for the destination
317     */
318    @MBeanInfo("Prioritized messages is enabled")
319    public boolean isPrioritizedMessages();
320    
321    /**
322     * @param value
323     * enable/disable caching on the destination
324     */
325    public void setUseCache(@MBeanInfo("cache") boolean value);
326
327    /**
328     * Returns all the current subscription MBeans matching this destination
329     * 
330     * @return the names of the subscriptions for this destination
331     */
332    @MBeanInfo("returns all the current subscription MBeans matching this destination")
333    ObjectName[] getSubscriptions() throws IOException, MalformedObjectNameException;
334
335
336    /**
337     * Returns the slow consumer strategy MBean for this destination
338     *
339     * @return the name of the slow consumer handler MBean for this destination
340     */
341    @MBeanInfo("returns the optional slowConsumer handler MBeans for this destination")
342    ObjectName getSlowConsumerStrategy() throws IOException, MalformedObjectNameException;
343
344}