This is an automated email from the ASF dual-hosted git repository.
cshannon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/main by this push:
new 39da75abd AMQ-9157 - Add utility methods for dispatched advisory
39da75abd is described below
commit 39da75abdb93542be8c7949b4e7c429c1a26f307
Author: Christopher L. Shannon (cshannon) <[email protected]>
AuthorDate: Fri Nov 11 08:23:25 2022 -0500
AMQ-9157 - Add utility methods for dispatched advisory
---
.../org/apache/activemq/advisory/AdvisorySupport.java | 18 ++++++++++++++++++
.../org/apache/activemq/advisory/AdvisoryTests.java | 4 ++++
2 files changed, 22 insertions(+)
diff --git
a/activemq-client/src/main/java/org/apache/activemq/advisory/AdvisorySupport.java
b/activemq-client/src/main/java/org/apache/activemq/advisory/AdvisorySupport.java
index 9b5bfb82c..5aee0c886 100644
---
a/activemq-client/src/main/java/org/apache/activemq/advisory/AdvisorySupport.java
+++
b/activemq-client/src/main/java/org/apache/activemq/advisory/AdvisorySupport.java
@@ -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
*/
diff --git
a/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
index 90762ef86..fd42cf3bf 100644
---
a/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
+++
b/activemq-unit-tests/src/test/java/org/apache/activemq/advisory/AdvisoryTests.java
@@ -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);