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 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 * 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 used by undelivered messages in bytes") 227 long getMemoryUsageByteCount(); 228 229 /** 230 * @return the amount of memory allocated to this destination 231 */ 232 @MBeanInfo("Memory limit, in bytes, used by 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 percentage of amount of temp usage used 243 */ 244 @MBeanInfo("The percentage of the temp usage limit used") 245 int getTempUsagePercentUsage(); 246 247 /** 248 * @return the amount of temp usage allocated to this destination 249 */ 250 @MBeanInfo("Temp usage limit, in bytes, assigned to this destination.") 251 long getTempUsageLimit(); 252 253 /** 254 * set the amount of temp usage allocated to this destination 255 * @param limit the amount of temp usage allocated to this destination 256 */ 257 void setTempUsageLimit(long limit); 258 259 /** 260 * @return the portion of memory from the broker memory limit for this destination 261 */ 262 @MBeanInfo("Portion of memory from the broker memory limit for this destination") 263 float getMemoryUsagePortion(); 264 265 /** 266 * set the portion of memory from the broker memory limit for this destination 267 * @param value 268 */ 269 void setMemoryUsagePortion(@MBeanInfo("bytes") float value); 270 271 /** 272 * Browses the current destination returning a list of messages 273 */ 274 @MBeanInfo("A list of all messages in the destination. Not HTML friendly.") 275 List<?> browseMessages() throws InvalidSelectorException; 276 277 /** 278 * Browses the current destination with the given selector returning a list 279 * of messages 280 */ 281 @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.") 282 List<?> browseMessages(String selector) throws InvalidSelectorException; 283 284 /** 285 * @return longest time a message is held by a destination 286 */ 287 @MBeanInfo("The longest time a message was held on this destination") 288 long getMaxEnqueueTime(); 289 290 /** 291 * @return shortest time a message is held by a destination 292 */ 293 @MBeanInfo("The shortest time a message was held on this destination") 294 long getMinEnqueueTime(); 295 296 @MBeanInfo("Average time a message was held on this destination.") 297 double getAverageEnqueueTime(); 298 299 @MBeanInfo("Average message size on this destination") 300 long getAverageMessageSize(); 301 302 @MBeanInfo("Max message size on this destination") 303 public long getMaxMessageSize(); 304 305 @MBeanInfo("Min message size on this destination") 306 public long getMinMessageSize(); 307 308 /** 309 * @return the producerFlowControl 310 */ 311 @MBeanInfo("Flow control is enabled for producers") 312 boolean isProducerFlowControl(); 313 314 /** 315 * @param producerFlowControl the producerFlowControl to set 316 */ 317 public void setProducerFlowControl(@MBeanInfo("producerFlowControl") boolean producerFlowControl); 318 319 /** 320 * @return if we treat consumers as alwaysRetroactive 321 */ 322 @MBeanInfo("Always treat consumers as retroactive") 323 boolean isAlwaysRetroactive(); 324 325 /** 326 * @param alwaysRetroactive set as always retroActive 327 */ 328 public void setAlwaysRetroactive(@MBeanInfo("alwaysRetroactive") boolean alwaysRetroactive); 329 330 /** 331 * Set's the interval at which warnings about producers being blocked by 332 * resource usage will be triggered. Values of 0 or less will disable 333 * warnings 334 * 335 * @param blockedProducerWarningInterval the interval at which warning about 336 * blocked producers will be triggered. 337 */ 338 public void setBlockedProducerWarningInterval(@MBeanInfo("blockedProducerWarningInterval") long blockedProducerWarningInterval); 339 340 /** 341 * 342 * @return the interval at which warning about blocked producers will be 343 * triggered. 344 */ 345 @MBeanInfo("Blocked Producer Warning Interval") 346 public long getBlockedProducerWarningInterval(); 347 348 /** 349 * @return the maxProducersToAudit 350 */ 351 @MBeanInfo("Maximum number of producers to audit") 352 public int getMaxProducersToAudit(); 353 354 /** 355 * @param maxProducersToAudit the maxProducersToAudit to set 356 */ 357 public void setMaxProducersToAudit(@MBeanInfo("maxProducersToAudit") int maxProducersToAudit); 358 359 /** 360 * @return the maxAuditDepth 361 */ 362 @MBeanInfo("Max audit depth") 363 public int getMaxAuditDepth(); 364 365 /** 366 * @param maxAuditDepth the maxAuditDepth to set 367 */ 368 public void setMaxAuditDepth(@MBeanInfo("maxAuditDepth") int maxAuditDepth); 369 370 /** 371 * @return the maximum number of message to be paged into the 372 * destination 373 */ 374 @MBeanInfo("Maximum number of messages to be paged in") 375 public int getMaxPageSize(); 376 377 /** 378 * @param pageSize 379 * Set the maximum number of messages to page into the destination 380 */ 381 public void setMaxPageSize(@MBeanInfo("pageSize") int pageSize); 382 383 /** 384 * @return true if caching is allowed of for the destination 385 */ 386 @MBeanInfo("Caching is allowed") 387 public boolean isUseCache(); 388 389 /** 390 * @return true if prioritized messages are enabled for the destination 391 */ 392 @MBeanInfo("Prioritized messages is enabled") 393 public boolean isPrioritizedMessages(); 394 395 /** 396 * @param value 397 * enable/disable caching on the destination 398 */ 399 public void setUseCache(@MBeanInfo("cache") boolean value); 400 401 /** 402 * Returns all the current subscription MBeans matching this destination 403 * 404 * @return the names of the subscriptions for this destination 405 */ 406 @MBeanInfo("Subscription MBeans matching this destination") 407 ObjectName[] getSubscriptions() throws IOException, MalformedObjectNameException; 408 409 410 /** 411 * Returns the slow consumer strategy MBean for this destination 412 * 413 * @return the name of the slow consumer handler MBean for this destination 414 */ 415 @MBeanInfo("Optional slowConsumer handler MBean for this destination") 416 ObjectName getSlowConsumerStrategy() throws IOException, MalformedObjectNameException; 417 418 /** 419 * @return A string of destination options, name value pairs as URL queryString. 420 */ 421 @MBeanInfo("Destination options as name value pairs in a URL queryString") 422 String getOptions(); 423 424 /** 425 * @return true if this is dead letter queue 426 */ 427 @MBeanInfo("Dead Letter Queue") 428 boolean isDLQ(); 429 430 /** 431 * @param value 432 * enable/disable the DLQ flag 433 */ 434 void setDLQ(boolean value); 435 436 @MBeanInfo("Number of messages blocked for flow control") 437 long getBlockedSends(); 438 439 @MBeanInfo("Average time (ms) messages have been blocked by flow control") 440 double getAverageBlockedTime(); 441 442 @MBeanInfo("Total time (ms) messages have been blocked by flow control") 443 long getTotalBlockedTime(); 444 445}