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