AMQ-9157 - Add utility methods for dispatched advisory

This commit is contained in:
Christopher L. Shannon (cshannon) 2022-11-11 08:23:25 -05:00
parent f473efe163
commit 39da75abdb
2 changed files with 22 additions and 0 deletions

View File

@ -577,6 +577,24 @@ public final class AdvisorySupport {
}
}
public static boolean isMessageDispatchedAdvisoryTopic(Destination destination) throws JMSException {
return isMessageDispatchedAdvisoryTopic(ActiveMQMessageTransformation.transformDestination(destination));
}
public static boolean isMessageDispatchedAdvisoryTopic(ActiveMQDestination destination) {
if (destination.isComposite()) {
ActiveMQDestination[] compositeDestinations = destination.getCompositeDestinations();
for (int i = 0; i < compositeDestinations.length; i++) {
if (isMessageDispatchedAdvisoryTopic(compositeDestinations[i])) {
return true;
}
}
return false;
} else {
return destination.isTopic() && destination.getPhysicalName().startsWith(MESSAGE_DISPATCHED_TOPIC_PREFIX);
}
}
/**
* Returns the agent topic which is used to send commands to the broker
*/

View File

@ -214,6 +214,10 @@ public class AdvisoryTests {
Topic advisoryTopic = AdvisorySupport.getMessageDispatchedAdvisoryTopic(
(ActiveMQDestination) queue);
//Test util method
assertTrue(AdvisorySupport.isMessageDispatchedAdvisoryTopic(advisoryTopic));
MessageConsumer advisoryConsumer = s.createConsumer(advisoryTopic);
// start throwing messages at the consumer
MessageProducer producer = s.createProducer(queue);