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.advisory; 018 019import java.util.ArrayList; 020 021import javax.jms.Destination; 022import javax.jms.JMSException; 023 024import org.apache.activemq.ActiveMQMessageTransformation; 025import org.apache.activemq.command.ActiveMQDestination; 026import org.apache.activemq.command.ActiveMQTopic; 027 028public final class AdvisorySupport { 029 public static final String ADVISORY_TOPIC_PREFIX = "ActiveMQ.Advisory."; 030 public static final ActiveMQTopic CONNECTION_ADVISORY_TOPIC = new ActiveMQTopic(ADVISORY_TOPIC_PREFIX 031 + "Connection"); 032 public static final ActiveMQTopic QUEUE_ADVISORY_TOPIC = new ActiveMQTopic(ADVISORY_TOPIC_PREFIX + "Queue"); 033 public static final ActiveMQTopic TOPIC_ADVISORY_TOPIC = new ActiveMQTopic(ADVISORY_TOPIC_PREFIX + "Topic"); 034 public static final ActiveMQTopic TEMP_QUEUE_ADVISORY_TOPIC = new ActiveMQTopic(ADVISORY_TOPIC_PREFIX + "TempQueue"); 035 public static final ActiveMQTopic TEMP_TOPIC_ADVISORY_TOPIC = new ActiveMQTopic(ADVISORY_TOPIC_PREFIX + "TempTopic"); 036 public static final String PRODUCER_ADVISORY_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "Producer."; 037 public static final String QUEUE_PRODUCER_ADVISORY_TOPIC_PREFIX = PRODUCER_ADVISORY_TOPIC_PREFIX + "Queue."; 038 public static final String TOPIC_PRODUCER_ADVISORY_TOPIC_PREFIX = PRODUCER_ADVISORY_TOPIC_PREFIX + "Topic."; 039 public static final String ANONYMOUS_PRODUCER_ADVISORY_TOPIC_PREFIX = PRODUCER_ADVISORY_TOPIC_PREFIX + "Anonymous"; 040 public static final String CONSUMER_ADVISORY_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "Consumer."; 041 public static final String VIRTUAL_DESTINATION_CONSUMER_ADVISORY_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "VirtualDestination.Consumer."; 042 public static final String QUEUE_CONSUMER_ADVISORY_TOPIC_PREFIX = CONSUMER_ADVISORY_TOPIC_PREFIX + "Queue."; 043 public static final String TOPIC_CONSUMER_ADVISORY_TOPIC_PREFIX = CONSUMER_ADVISORY_TOPIC_PREFIX + "Topic."; 044 public static final String QUEUE_VIRTUAL_DESTINATION_CONSUMER_ADVISORY_TOPIC_PREFIX = VIRTUAL_DESTINATION_CONSUMER_ADVISORY_TOPIC_PREFIX + "Queue."; 045 public static final String TOPIC_VIRTUAL_DESTINATION_CONSUMER_ADVISORY_TOPIC_PREFIX = VIRTUAL_DESTINATION_CONSUMER_ADVISORY_TOPIC_PREFIX + "Topic."; 046 public static final String EXPIRED_TOPIC_MESSAGES_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "Expired.Topic."; 047 public static final String EXPIRED_QUEUE_MESSAGES_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "Expired.Queue."; 048 public static final String NO_TOPIC_CONSUMERS_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "NoConsumer.Topic."; 049 public static final String NO_QUEUE_CONSUMERS_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "NoConsumer.Queue."; 050 public static final String SLOW_CONSUMER_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "SlowConsumer."; 051 public static final String FAST_PRODUCER_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "FastProducer."; 052 public static final String MESSAGE_DISCAREDED_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "MessageDiscarded."; 053 public static final String FULL_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "FULL."; 054 public static final String MESSAGE_DELIVERED_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "MessageDelivered."; 055 public static final String MESSAGE_CONSUMED_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "MessageConsumed."; 056 public static final String MESSAGE_DLQ_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "MessageDLQd."; 057 public static final String MASTER_BROKER_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "MasterBroker"; 058 public static final String NETWORK_BRIDGE_TOPIC_PREFIX = ADVISORY_TOPIC_PREFIX + "NetworkBridge"; 059 public static final String NETWORK_BRIDGE_FORWARD_FAILURE_TOPIC_PREFIX = NETWORK_BRIDGE_TOPIC_PREFIX + ".ForwardFailure"; 060 public static final String AGENT_TOPIC = "ActiveMQ.Agent"; 061 public static final String ADIVSORY_MESSAGE_TYPE = "Advisory"; 062 public static final String MSG_PROPERTY_ORIGIN_BROKER_ID = "originBrokerId"; 063 public static final String MSG_PROPERTY_ORIGIN_BROKER_NAME = "originBrokerName"; 064 public static final String MSG_PROPERTY_ORIGIN_BROKER_URL = "originBrokerURL"; 065 public static final String MSG_PROPERTY_USAGE_NAME = "usageName"; 066 public static final String MSG_PROPERTY_USAGE_COUNT = "usageCount"; 067 068 public static final String MSG_PROPERTY_CONSUMER_ID = "consumerId"; 069 public static final String MSG_PROPERTY_PRODUCER_ID = "producerId"; 070 public static final String MSG_PROPERTY_MESSAGE_ID = "orignalMessageId"; 071 public static final String MSG_PROPERTY_DESTINATION = "orignalDestination"; 072 public static final String MSG_PROPERTY_CONSUMER_COUNT = "consumerCount"; 073 public static final String MSG_PROPERTY_DISCARDED_COUNT = "discardedCount"; 074 075 public static final ActiveMQTopic ALL_DESTINATIONS_COMPOSITE_ADVISORY_TOPIC = new ActiveMQTopic( 076 TOPIC_ADVISORY_TOPIC.getPhysicalName() + "," + QUEUE_ADVISORY_TOPIC.getPhysicalName() + "," + 077 TEMP_QUEUE_ADVISORY_TOPIC.getPhysicalName() + "," + TEMP_TOPIC_ADVISORY_TOPIC.getPhysicalName()); 078 public static final ActiveMQTopic TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC = new ActiveMQTopic( 079 TEMP_QUEUE_ADVISORY_TOPIC.getPhysicalName() + "," + TEMP_TOPIC_ADVISORY_TOPIC.getPhysicalName()); 080 private static final ActiveMQTopic AGENT_TOPIC_DESTINATION = new ActiveMQTopic(AGENT_TOPIC); 081 082 private AdvisorySupport() { 083 } 084 085 public static ActiveMQTopic getConnectionAdvisoryTopic() { 086 return CONNECTION_ADVISORY_TOPIC; 087 } 088 089 public static ActiveMQTopic[] getAllDestinationAdvisoryTopics(Destination destination) throws JMSException { 090 return getAllDestinationAdvisoryTopics(ActiveMQMessageTransformation.transformDestination(destination)); 091 } 092 093 public static ActiveMQTopic[] getAllDestinationAdvisoryTopics(ActiveMQDestination destination) throws JMSException { 094 ArrayList<ActiveMQTopic> result = new ArrayList<ActiveMQTopic>(); 095 096 result.add(getConsumerAdvisoryTopic(destination)); 097 result.add(getProducerAdvisoryTopic(destination)); 098 result.add(getExpiredMessageTopic(destination)); 099 result.add(getNoConsumersAdvisoryTopic(destination)); 100 result.add(getSlowConsumerAdvisoryTopic(destination)); 101 result.add(getFastProducerAdvisoryTopic(destination)); 102 result.add(getMessageDiscardedAdvisoryTopic(destination)); 103 result.add(getMessageDeliveredAdvisoryTopic(destination)); 104 result.add(getMessageConsumedAdvisoryTopic(destination)); 105 result.add(getMessageDLQdAdvisoryTopic(destination)); 106 result.add(getFullAdvisoryTopic(destination)); 107 108 return result.toArray(new ActiveMQTopic[0]); 109 } 110 111 public static ActiveMQTopic getConsumerAdvisoryTopic(Destination destination) throws JMSException { 112 return getConsumerAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 113 } 114 115 public static ActiveMQTopic getConsumerAdvisoryTopic(ActiveMQDestination destination) { 116 String prefix; 117 if (destination.isQueue()) { 118 prefix = QUEUE_CONSUMER_ADVISORY_TOPIC_PREFIX; 119 } else { 120 prefix = TOPIC_CONSUMER_ADVISORY_TOPIC_PREFIX; 121 } 122 return getAdvisoryTopic(destination, prefix, true); 123 } 124 125 public static ActiveMQTopic getVirtualDestinationConsumerAdvisoryTopic(ActiveMQDestination destination) { 126 String prefix; 127 if (destination.isQueue()) { 128 prefix = QUEUE_VIRTUAL_DESTINATION_CONSUMER_ADVISORY_TOPIC_PREFIX; 129 } else { 130 prefix = TOPIC_VIRTUAL_DESTINATION_CONSUMER_ADVISORY_TOPIC_PREFIX; 131 } 132 return getAdvisoryTopic(destination, prefix, true); 133 } 134 135 public static ActiveMQTopic getProducerAdvisoryTopic(Destination destination) throws JMSException { 136 return getProducerAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 137 } 138 139 public static ActiveMQTopic getProducerAdvisoryTopic(ActiveMQDestination destination) { 140 String prefix; 141 if (destination == null) { 142 prefix = ANONYMOUS_PRODUCER_ADVISORY_TOPIC_PREFIX; 143 } else if (destination.isQueue()) { 144 prefix = QUEUE_PRODUCER_ADVISORY_TOPIC_PREFIX; 145 } else { 146 prefix = TOPIC_PRODUCER_ADVISORY_TOPIC_PREFIX; 147 } 148 return getAdvisoryTopic(destination, prefix, false); 149 } 150 151 private static ActiveMQTopic getAdvisoryTopic(ActiveMQDestination destination, String prefix, boolean consumerTopics) { 152 return destination != null ? new ActiveMQTopic(prefix + destination.getPhysicalName().replaceAll(",", "‚")): 153 new ActiveMQTopic(prefix); 154 } 155 156 public static ActiveMQTopic getExpiredMessageTopic(Destination destination) throws JMSException { 157 return getExpiredMessageTopic(ActiveMQMessageTransformation.transformDestination(destination)); 158 } 159 160 public static ActiveMQTopic getExpiredMessageTopic(ActiveMQDestination destination) { 161 if (destination.isQueue()) { 162 return getExpiredQueueMessageAdvisoryTopic(destination); 163 } 164 return getExpiredTopicMessageAdvisoryTopic(destination); 165 } 166 167 public static ActiveMQTopic getExpiredTopicMessageAdvisoryTopic(ActiveMQDestination destination) { 168 String name = EXPIRED_TOPIC_MESSAGES_TOPIC_PREFIX + destination.getPhysicalName(); 169 return new ActiveMQTopic(name); 170 } 171 172 public static ActiveMQTopic getExpiredQueueMessageAdvisoryTopic(Destination destination) throws JMSException { 173 return getExpiredQueueMessageAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 174 } 175 176 public static ActiveMQTopic getExpiredQueueMessageAdvisoryTopic(ActiveMQDestination destination) { 177 String name = EXPIRED_QUEUE_MESSAGES_TOPIC_PREFIX + destination.getPhysicalName(); 178 return new ActiveMQTopic(name); 179 } 180 181 public static ActiveMQTopic getNoConsumersAdvisoryTopic(Destination destination) throws JMSException { 182 return getExpiredMessageTopic(ActiveMQMessageTransformation.transformDestination(destination)); 183 } 184 185 public static ActiveMQTopic getNoConsumersAdvisoryTopic(ActiveMQDestination destination) { 186 if (destination.isQueue()) { 187 return getNoQueueConsumersAdvisoryTopic(destination); 188 } 189 return getNoTopicConsumersAdvisoryTopic(destination); 190 } 191 192 public static ActiveMQTopic getNoTopicConsumersAdvisoryTopic(Destination destination) throws JMSException { 193 return getNoTopicConsumersAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 194 } 195 196 public static ActiveMQTopic getNoTopicConsumersAdvisoryTopic(ActiveMQDestination destination) { 197 String name = NO_TOPIC_CONSUMERS_TOPIC_PREFIX + destination.getPhysicalName(); 198 return new ActiveMQTopic(name); 199 } 200 201 public static ActiveMQTopic getNoQueueConsumersAdvisoryTopic(Destination destination) throws JMSException { 202 return getNoQueueConsumersAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 203 } 204 205 public static ActiveMQTopic getNoQueueConsumersAdvisoryTopic(ActiveMQDestination destination) { 206 String name = NO_QUEUE_CONSUMERS_TOPIC_PREFIX + destination.getPhysicalName(); 207 return new ActiveMQTopic(name); 208 } 209 210 public static ActiveMQTopic getSlowConsumerAdvisoryTopic(Destination destination) throws JMSException { 211 return getSlowConsumerAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 212 } 213 214 public static ActiveMQTopic getSlowConsumerAdvisoryTopic(ActiveMQDestination destination) { 215 String name = SLOW_CONSUMER_TOPIC_PREFIX + destination.getDestinationTypeAsString() + "." 216 + destination.getPhysicalName(); 217 return new ActiveMQTopic(name); 218 } 219 220 public static ActiveMQTopic getFastProducerAdvisoryTopic(Destination destination) throws JMSException { 221 return getFastProducerAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 222 } 223 224 public static ActiveMQTopic getFastProducerAdvisoryTopic(ActiveMQDestination destination) { 225 String name = FAST_PRODUCER_TOPIC_PREFIX + destination.getDestinationTypeAsString() + "." 226 + destination.getPhysicalName(); 227 return new ActiveMQTopic(name); 228 } 229 230 public static ActiveMQTopic getMessageDiscardedAdvisoryTopic(Destination destination) throws JMSException { 231 return getMessageDiscardedAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 232 } 233 234 public static ActiveMQTopic getMessageDiscardedAdvisoryTopic(ActiveMQDestination destination) { 235 String name = MESSAGE_DISCAREDED_TOPIC_PREFIX + destination.getDestinationTypeAsString() + "." 236 + destination.getPhysicalName(); 237 return new ActiveMQTopic(name); 238 } 239 240 public static ActiveMQTopic getMessageDeliveredAdvisoryTopic(Destination destination) throws JMSException { 241 return getMessageDeliveredAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 242 } 243 244 public static ActiveMQTopic getMessageDeliveredAdvisoryTopic(ActiveMQDestination destination) { 245 String name = MESSAGE_DELIVERED_TOPIC_PREFIX + destination.getDestinationTypeAsString() + "." 246 + destination.getPhysicalName(); 247 return new ActiveMQTopic(name); 248 } 249 250 public static ActiveMQTopic getMessageConsumedAdvisoryTopic(Destination destination) throws JMSException { 251 return getMessageConsumedAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 252 } 253 254 public static ActiveMQTopic getMessageConsumedAdvisoryTopic(ActiveMQDestination destination) { 255 String name = MESSAGE_CONSUMED_TOPIC_PREFIX + destination.getDestinationTypeAsString() + "." 256 + destination.getPhysicalName(); 257 return new ActiveMQTopic(name); 258 } 259 260 public static ActiveMQTopic getMessageDLQdAdvisoryTopic(ActiveMQDestination destination) { 261 String name = MESSAGE_DLQ_TOPIC_PREFIX + destination.getDestinationTypeAsString() + "." 262 + destination.getPhysicalName(); 263 return new ActiveMQTopic(name); 264 } 265 266 public static ActiveMQTopic getMasterBrokerAdvisoryTopic() { 267 return new ActiveMQTopic(MASTER_BROKER_TOPIC_PREFIX); 268 } 269 270 public static ActiveMQTopic getNetworkBridgeAdvisoryTopic() { 271 return new ActiveMQTopic(NETWORK_BRIDGE_TOPIC_PREFIX); 272 } 273 274 public static ActiveMQTopic getFullAdvisoryTopic(Destination destination) throws JMSException { 275 return getFullAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 276 } 277 278 public static ActiveMQTopic getFullAdvisoryTopic(ActiveMQDestination destination) { 279 String name = FULL_TOPIC_PREFIX + destination.getDestinationTypeAsString() + "." 280 + destination.getPhysicalName(); 281 return new ActiveMQTopic(name); 282 } 283 284 public static ActiveMQTopic getDestinationAdvisoryTopic(Destination destination) throws JMSException { 285 return getDestinationAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 286 } 287 288 public static ActiveMQTopic getDestinationAdvisoryTopic(ActiveMQDestination destination) { 289 switch (destination.getDestinationType()) { 290 case ActiveMQDestination.QUEUE_TYPE: 291 return QUEUE_ADVISORY_TOPIC; 292 case ActiveMQDestination.TOPIC_TYPE: 293 return TOPIC_ADVISORY_TOPIC; 294 case ActiveMQDestination.TEMP_QUEUE_TYPE: 295 return TEMP_QUEUE_ADVISORY_TOPIC; 296 case ActiveMQDestination.TEMP_TOPIC_TYPE: 297 return TEMP_TOPIC_ADVISORY_TOPIC; 298 default: 299 throw new RuntimeException("Unknown destination type: " + destination.getDestinationType()); 300 } 301 } 302 303 public static boolean isDestinationAdvisoryTopic(Destination destination) throws JMSException { 304 return isDestinationAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 305 } 306 307 public static boolean isTempDestinationAdvisoryTopic(ActiveMQDestination destination) { 308 if (destination.isComposite()) { 309 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 310 for (int i = 0; i < compositeDestinations.length; i++) { 311 if (!isTempDestinationAdvisoryTopic(compositeDestinations[i])) { 312 return false; 313 } 314 } 315 return true; 316 } else { 317 return destination.equals(TEMP_QUEUE_ADVISORY_TOPIC) || destination.equals(TEMP_TOPIC_ADVISORY_TOPIC); 318 } 319 } 320 321 public static boolean isDestinationAdvisoryTopic(ActiveMQDestination destination) { 322 if (destination.isComposite()) { 323 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 324 for (int i = 0; i < compositeDestinations.length; i++) { 325 if (isDestinationAdvisoryTopic(compositeDestinations[i])) { 326 return true; 327 } 328 } 329 return false; 330 } else { 331 return destination.equals(TEMP_QUEUE_ADVISORY_TOPIC) || destination.equals(TEMP_TOPIC_ADVISORY_TOPIC) 332 || destination.equals(QUEUE_ADVISORY_TOPIC) || destination.equals(TOPIC_ADVISORY_TOPIC); 333 } 334 } 335 336 public static boolean isAdvisoryTopic(Destination destination) throws JMSException { 337 return isAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 338 } 339 340 public static boolean isAdvisoryTopic(ActiveMQDestination destination) { 341 if (destination != null) { 342 if (destination.isComposite()) { 343 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 344 for (int i = 0; i < compositeDestinations.length; i++) { 345 if (isAdvisoryTopic(compositeDestinations[i])) { 346 return true; 347 } 348 } 349 return false; 350 } else { 351 return destination.isTopic() && destination.getPhysicalName().startsWith(ADVISORY_TOPIC_PREFIX); 352 } 353 } 354 return false; 355 } 356 357 public static boolean isConnectionAdvisoryTopic(Destination destination) throws JMSException { 358 return isConnectionAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 359 } 360 361 public static boolean isConnectionAdvisoryTopic(ActiveMQDestination destination) { 362 if (destination.isComposite()) { 363 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 364 for (int i = 0; i < compositeDestinations.length; i++) { 365 if (isConnectionAdvisoryTopic(compositeDestinations[i])) { 366 return true; 367 } 368 } 369 return false; 370 } else { 371 return destination.equals(CONNECTION_ADVISORY_TOPIC); 372 } 373 } 374 375 public static boolean isProducerAdvisoryTopic(Destination destination) throws JMSException { 376 return isProducerAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 377 } 378 379 public static boolean isProducerAdvisoryTopic(ActiveMQDestination destination) { 380 if (destination.isComposite()) { 381 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 382 for (int i = 0; i < compositeDestinations.length; i++) { 383 if (isProducerAdvisoryTopic(compositeDestinations[i])) { 384 return true; 385 } 386 } 387 return false; 388 } else { 389 return destination.isTopic() && destination.getPhysicalName().startsWith(PRODUCER_ADVISORY_TOPIC_PREFIX); 390 } 391 } 392 393 public static boolean isConsumerAdvisoryTopic(Destination destination) throws JMSException { 394 return isConsumerAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 395 } 396 397 public static boolean isConsumerAdvisoryTopic(ActiveMQDestination destination) { 398 if (destination.isComposite()) { 399 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 400 for (int i = 0; i < compositeDestinations.length; i++) { 401 if (isConsumerAdvisoryTopic(compositeDestinations[i])) { 402 return true; 403 } 404 } 405 return false; 406 } else { 407 return destination.isTopic() && destination.getPhysicalName().startsWith(CONSUMER_ADVISORY_TOPIC_PREFIX); 408 } 409 } 410 411 public static boolean isVirtualDestinationConsumerAdvisoryTopic(Destination destination) throws JMSException { 412 return isVirtualDestinationConsumerAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 413 } 414 415 public static boolean isVirtualDestinationConsumerAdvisoryTopic(ActiveMQDestination destination) { 416 if (destination.isComposite()) { 417 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 418 for (int i = 0; i < compositeDestinations.length; i++) { 419 if (isVirtualDestinationConsumerAdvisoryTopic(compositeDestinations[i])) { 420 return true; 421 } 422 } 423 return false; 424 } else { 425 return destination.isTopic() && destination.getPhysicalName().startsWith(VIRTUAL_DESTINATION_CONSUMER_ADVISORY_TOPIC_PREFIX); 426 } 427 } 428 429 public static boolean isSlowConsumerAdvisoryTopic(Destination destination) throws JMSException { 430 return isSlowConsumerAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 431 } 432 433 public static boolean isSlowConsumerAdvisoryTopic(ActiveMQDestination destination) { 434 if (destination.isComposite()) { 435 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 436 for (int i = 0; i < compositeDestinations.length; i++) { 437 if (isSlowConsumerAdvisoryTopic(compositeDestinations[i])) { 438 return true; 439 } 440 } 441 return false; 442 } else { 443 return destination.isTopic() && destination.getPhysicalName().startsWith(SLOW_CONSUMER_TOPIC_PREFIX); 444 } 445 } 446 447 public static boolean isFastProducerAdvisoryTopic(Destination destination) throws JMSException { 448 return isFastProducerAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 449 } 450 451 public static boolean isFastProducerAdvisoryTopic(ActiveMQDestination destination) { 452 if (destination.isComposite()) { 453 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 454 for (int i = 0; i < compositeDestinations.length; i++) { 455 if (isFastProducerAdvisoryTopic(compositeDestinations[i])) { 456 return true; 457 } 458 } 459 return false; 460 } else { 461 return destination.isTopic() && destination.getPhysicalName().startsWith(FAST_PRODUCER_TOPIC_PREFIX); 462 } 463 } 464 465 public static boolean isMessageConsumedAdvisoryTopic(Destination destination) throws JMSException { 466 return isMessageConsumedAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 467 } 468 469 public static boolean isMessageConsumedAdvisoryTopic(ActiveMQDestination destination) { 470 if (destination.isComposite()) { 471 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 472 for (int i = 0; i < compositeDestinations.length; i++) { 473 if (isMessageConsumedAdvisoryTopic(compositeDestinations[i])) { 474 return true; 475 } 476 } 477 return false; 478 } else { 479 return destination.isTopic() && destination.getPhysicalName().startsWith(MESSAGE_CONSUMED_TOPIC_PREFIX); 480 } 481 } 482 483 public static boolean isMasterBrokerAdvisoryTopic(Destination destination) throws JMSException { 484 return isMasterBrokerAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 485 } 486 487 public static boolean isMasterBrokerAdvisoryTopic(ActiveMQDestination destination) { 488 if (destination.isComposite()) { 489 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 490 for (int i = 0; i < compositeDestinations.length; i++) { 491 if (isMasterBrokerAdvisoryTopic(compositeDestinations[i])) { 492 return true; 493 } 494 } 495 return false; 496 } else { 497 return destination.isTopic() && destination.getPhysicalName().startsWith(MASTER_BROKER_TOPIC_PREFIX); 498 } 499 } 500 501 public static boolean isMessageDeliveredAdvisoryTopic(Destination destination) throws JMSException { 502 return isMessageDeliveredAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 503 } 504 505 public static boolean isMessageDeliveredAdvisoryTopic(ActiveMQDestination destination) { 506 if (destination.isComposite()) { 507 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 508 for (int i = 0; i < compositeDestinations.length; i++) { 509 if (isMessageDeliveredAdvisoryTopic(compositeDestinations[i])) { 510 return true; 511 } 512 } 513 return false; 514 } else { 515 return destination.isTopic() && destination.getPhysicalName().startsWith(MESSAGE_DELIVERED_TOPIC_PREFIX); 516 } 517 } 518 519 public static boolean isMessageDiscardedAdvisoryTopic(Destination destination) throws JMSException { 520 return isMessageDiscardedAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 521 } 522 523 public static boolean isMessageDiscardedAdvisoryTopic(ActiveMQDestination destination) { 524 if (destination.isComposite()) { 525 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 526 for (int i = 0; i < compositeDestinations.length; i++) { 527 if (isMessageDiscardedAdvisoryTopic(compositeDestinations[i])) { 528 return true; 529 } 530 } 531 return false; 532 } else { 533 return destination.isTopic() && destination.getPhysicalName().startsWith(MESSAGE_DISCAREDED_TOPIC_PREFIX); 534 } 535 } 536 537 public static boolean isFullAdvisoryTopic(Destination destination) throws JMSException { 538 return isFullAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 539 } 540 541 public static boolean isFullAdvisoryTopic(ActiveMQDestination destination) { 542 if (destination.isComposite()) { 543 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 544 for (int i = 0; i < compositeDestinations.length; i++) { 545 if (isFullAdvisoryTopic(compositeDestinations[i])) { 546 return true; 547 } 548 } 549 return false; 550 } else { 551 return destination.isTopic() && destination.getPhysicalName().startsWith(FULL_TOPIC_PREFIX); 552 } 553 } 554 555 public static boolean isNetworkBridgeAdvisoryTopic(Destination destination) throws JMSException { 556 return isNetworkBridgeAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination)); 557 } 558 559 public static boolean isNetworkBridgeAdvisoryTopic(ActiveMQDestination destination) { 560 if (destination.isComposite()) { 561 ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations(); 562 for (int i = 0; i < compositeDestinations.length; i++) { 563 if (isNetworkBridgeAdvisoryTopic(compositeDestinations[i])) { 564 return true; 565 } 566 } 567 return false; 568 } else { 569 return destination.isTopic() && destination.getPhysicalName().startsWith(NETWORK_BRIDGE_TOPIC_PREFIX); 570 } 571 } 572 573 /** 574 * Returns the agent topic which is used to send commands to the broker 575 */ 576 public static Destination getAgentDestination() { 577 return AGENT_TOPIC_DESTINATION; 578 } 579 580 public static ActiveMQTopic getNetworkBridgeForwardFailureAdvisoryTopic() { 581 return new ActiveMQTopic(NETWORK_BRIDGE_FORWARD_FAILURE_TOPIC_PREFIX); 582 } 583}