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