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;
022
023import javax.jms.InvalidSelectorException;
024import javax.management.MalformedObjectNameException;
025import javax.management.ObjectName;
026import javax.management.openmbean.CompositeData;
027import javax.management.openmbean.OpenDataException;
028import javax.management.openmbean.TabularData;
029
030public 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 management 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 acknowledged by network subscriptions from the
074     * destination.
075     *
076     * @return The number of messages that have been acknowledged by network subscriptions from the
077     *         destination.
078     */
079    @MBeanInfo("Number of messages that have been forwarded (to a networked broker) from the destination.")
080    long getForwardCount();
081
082    /**
083     * Returns the number of messages that have been dispatched but not
084     * acknowledged
085     *
086     * @return The number of messages that have been dispatched but not
087     * acknowledged
088     */
089    @MBeanInfo("Number of messages that have been dispatched to, but not acknowledged by, consumers.")
090    long getInFlightCount();
091
092    /**
093     * Returns the number of messages that have expired
094     *
095     * @return The number of messages that have expired
096     */
097    @MBeanInfo("Number of messages that have been expired.")
098    long getExpiredCount();
099
100    /**
101     * Returns the number of consumers subscribed this destination.
102     *
103     * @return The number of consumers subscribed this destination.
104     */
105    @MBeanInfo("Number of consumers subscribed to this destination.")
106    long getConsumerCount();
107
108    /**
109     * @return the number of producers publishing to the destination
110     */
111    @MBeanInfo("Number of producers publishing to this destination")
112    long getProducerCount();
113
114    /**
115     * Returns the number of messages in this destination which are yet to be
116     * consumed
117     *
118     * @return Returns the number of messages in this destination which are yet
119     *         to be consumed
120     */
121    @MBeanInfo("Number of messages in the destination which are yet to be consumed.  Potentially dispatched but unacknowledged.")
122    long getQueueSize();
123
124    /**
125     * Returns the memory size of all messages in this destination's store
126     *
127     * @return Returns the memory size of all messages in this destination's store
128     */
129    @MBeanInfo("The memory size of all messages in this destination's store.")
130    long getStoreMessageSize();
131
132    /**
133     * @return An array of all the messages in the destination's queue.
134     */
135    @MBeanInfo("An array of all messages in the destination. Not HTML friendly.")
136    CompositeData[] browse() throws OpenDataException;
137
138    /**
139     * @return A list of all the messages in the destination's queue.
140     */
141    @MBeanInfo("A list of all messages in the destination. Not HTML friendly.")
142    TabularData browseAsTable() throws OpenDataException;
143
144    /**
145     * @return An array of all the messages in the destination's queue.
146     * @throws InvalidSelectorException
147     */
148    @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.")
149    CompositeData[] browse(@MBeanInfo("selector") String selector) throws OpenDataException, InvalidSelectorException;
150
151    /**
152     * @return A list of all the messages in the destination's queue.
153     * @throws InvalidSelectorException
154     */
155    @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.")
156    TabularData browseAsTable(@MBeanInfo("selector") String selector) throws OpenDataException, InvalidSelectorException;
157
158    /**
159     * Sends a TextMesage to the destination.
160     *
161     * @param body the text to send
162     * @return the message id of the message sent.
163     * @throws Exception
164     */
165    @MBeanInfo("Sends a TextMessage to the destination.")
166    String sendTextMessage(@MBeanInfo("body") String body) throws Exception;
167
168    /**
169     * Sends a TextMessage to the destination.
170     *
171     * @param properties the message properties to set as a comma sep name=value list. Can only
172     *                contain Strings maped to primitive types or JMS properties. eg: body=hi,JMSReplyTo=Queue2
173     * @return the message id of the message sent.
174     * @throws Exception
175     */
176    @MBeanInfo("Sends a TextMessage to the destination.")
177    public String sendTextMessageWithProperties(String properties) throws Exception;
178
179    /**
180     * Sends a TextMesage to the destination.
181     *
182     * @param headers the message headers and properties to set. Can only
183     *                container Strings maped to primitive types.
184     * @param body the text to send
185     * @return the message id of the message sent.
186     * @throws Exception
187     */
188    @MBeanInfo("Sends a TextMessage to the destination.")
189    String sendTextMessage(@MBeanInfo("headers") Map<?,?> headers, @MBeanInfo("body") String body) throws Exception;
190
191    /**
192     * Sends a TextMesage to the destination.
193     * @param body the text to send
194     * @param user
195     * @param password
196     * @return a string value
197     * @throws Exception
198     */
199    @MBeanInfo("Sends a TextMessage to a password-protected destination.")
200    String sendTextMessage(@MBeanInfo("body") String body, @MBeanInfo("user") String user, @MBeanInfo("password") String password) throws Exception;
201
202    /**
203     *
204     * @param headers the message headers and properties to set. Can only
205     *                container Strings maped to primitive types.
206     * @param body the text to send
207     * @param user
208     * @param password
209     *
210     * @return a string value
211     *
212     * @throws Exception
213     */
214    @MBeanInfo("Sends a TextMessage to a password-protected destination.")
215    String sendTextMessage(@MBeanInfo("headers") Map<String,String> headers, @MBeanInfo("body") String body, @MBeanInfo("user") String user, @MBeanInfo("password") String password) throws Exception;
216
217    /**
218     * @return the percentage of amount of memory used
219     */
220    @MBeanInfo("The percentage of the memory limit used")
221    int getMemoryPercentUsage();
222
223    /**
224     * @return the amount of memory currently used by this destination
225     */
226    @MBeanInfo("Memory usage, in bytes, used by undelivered messages")
227    long getMemoryUsageByteCount();
228
229    /**
230     * @return the amount of memory allocated to this destination
231     */
232    @MBeanInfo("Memory limit, in bytes, used for holding undelivered messages before paging to temporary storage.")
233    long getMemoryLimit();
234
235    /**
236     * set the amount of memory allocated to this destination
237     * @param limit
238     */
239    void setMemoryLimit(long limit);
240
241    /**
242     * @return the portion of memory from the broker memory limit for this destination
243     */
244    @MBeanInfo("Portion of memory from the broker memory limit for this destination")
245    float getMemoryUsagePortion();
246
247    /**
248     * set the portion of memory from the broker memory limit for this destination
249     * @param value
250     */
251    void setMemoryUsagePortion(@MBeanInfo("bytes") float value);
252
253    /**
254     * Browses the current destination returning a list of messages
255     */
256    @MBeanInfo("A list of all messages in the destination. Not HTML friendly.")
257    List<?> browseMessages() throws InvalidSelectorException;
258
259    /**
260     * Browses the current destination with the given selector returning a list
261     * of messages
262     */
263    @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.")
264    List<?> browseMessages(String selector) throws InvalidSelectorException;
265
266    /**
267     * @return longest time a message is held by a destination
268     */
269    @MBeanInfo("The longest time a message has been held this destination.")
270    long getMaxEnqueueTime();
271
272    /**
273     * @return shortest time a message is held by a destination
274     */
275    @MBeanInfo("The shortest time a message has been held this destination.")
276    long getMinEnqueueTime();
277
278    @MBeanInfo("Average time a message has been held this destination.")
279    double getAverageEnqueueTime();
280
281    @MBeanInfo("Average message size on this destination")
282    long getAverageMessageSize();
283
284    @MBeanInfo("Max message size on this destination")
285    public long getMaxMessageSize();
286
287    @MBeanInfo("Min message size on this destination")
288    public long getMinMessageSize();
289
290    /**
291     * @return the producerFlowControl
292     */
293    @MBeanInfo("Producers are flow controlled")
294    boolean isProducerFlowControl();
295
296    /**
297     * @param producerFlowControl the producerFlowControl to set
298     */
299    public void setProducerFlowControl(@MBeanInfo("producerFlowControl") boolean producerFlowControl);
300
301    /**
302     * @return if we treat consumers as alwaysRetroactive
303     */
304    @MBeanInfo("Always treat consumers as retroActive")
305    boolean isAlwaysRetroactive();
306
307    /**
308     * @param alwaysRetroactive set as always retroActive
309     */
310    public void setAlwaysRetroactive(@MBeanInfo("alwaysRetroactive") boolean alwaysRetroactive);
311
312    /**
313     * Set's the interval at which warnings about producers being blocked by
314     * resource usage will be triggered. Values of 0 or less will disable
315     * warnings
316     *
317     * @param blockedProducerWarningInterval the interval at which warning about
318     *            blocked producers will be triggered.
319     */
320    public void setBlockedProducerWarningInterval(@MBeanInfo("blockedProducerWarningInterval")  long blockedProducerWarningInterval);
321
322    /**
323     *
324     * @return the interval at which warning about blocked producers will be
325     *         triggered.
326     */
327    @MBeanInfo("Blocked Producer Warning Interval")
328    public long getBlockedProducerWarningInterval();
329
330    /**
331     * @return the maxProducersToAudit
332     */
333    @MBeanInfo("Maximum number of producers to audit")
334    public int getMaxProducersToAudit();
335
336    /**
337     * @param maxProducersToAudit the maxProducersToAudit to set
338     */
339    public void setMaxProducersToAudit(@MBeanInfo("maxProducersToAudit") int maxProducersToAudit);
340
341    /**
342     * @return the maxAuditDepth
343     */
344    @MBeanInfo("Max audit depth")
345    public int getMaxAuditDepth();
346
347    /**
348     * @param maxAuditDepth the maxAuditDepth to set
349     */
350    public void setMaxAuditDepth(@MBeanInfo("maxAuditDepth") int maxAuditDepth);
351
352    /**
353     * @return the maximum number of message to be paged into the
354     * destination
355     */
356    @MBeanInfo("Maximum number of messages to be paged in")
357    public int getMaxPageSize();
358
359    /**
360     * @param pageSize
361     * Set the maximum number of messages to page into the destination
362     */
363    public void setMaxPageSize(@MBeanInfo("pageSize") int pageSize);
364
365    /**
366     * @return true if caching is allowed of for the destination
367     */
368    @MBeanInfo("Caching is allowed")
369    public boolean isUseCache();
370
371    /**
372     * @return true if prioritized messages are enabled for the destination
373     */
374    @MBeanInfo("Prioritized messages is enabled")
375    public boolean isPrioritizedMessages();
376
377    /**
378     * @param value
379     * enable/disable caching on the destination
380     */
381    public void setUseCache(@MBeanInfo("cache") boolean value);
382
383    /**
384     * Returns all the current subscription MBeans matching this destination
385     *
386     * @return the names of the subscriptions for this destination
387     */
388    @MBeanInfo("returns all the current subscription MBeans matching this destination")
389    ObjectName[] getSubscriptions() throws IOException, MalformedObjectNameException;
390
391
392    /**
393     * Returns the slow consumer strategy MBean for this destination
394     *
395     * @return the name of the slow consumer handler MBean for this destination
396     */
397    @MBeanInfo("returns the optional slowConsumer handler MBeans for this destination")
398    ObjectName getSlowConsumerStrategy() throws IOException, MalformedObjectNameException;
399
400    /**
401     * @return A string of destination options, name value pairs as URL queryString.
402     */
403    @MBeanInfo("returns the destination options, name value pairs as URL queryString")
404    String getOptions();
405
406    /**
407     * @return true if this is dead letter queue
408     */
409    @MBeanInfo("Dead Letter Queue")
410    boolean isDLQ();
411
412    @MBeanInfo("Get number of messages blocked for Flow Control")
413    long getBlockedSends();
414
415    @MBeanInfo("get the average time (ms) a message is blocked for Flow Control")
416    double getAverageBlockedTime();
417
418    @MBeanInfo("Get the total time (ms) messages are blocked for Flow Control")
419    long getTotalBlockedTime();
420
421}