This is an automated email from the ASF dual-hosted git repository.
jbonofre 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 c05e794c42 AMQ-9854 Add wait for broker to process disconnect before
publishing … (#1646)
c05e794c42 is described below
commit c05e794c4215aaff598a479ac165bb613395e5b8
Author: Jean-Louis Monteiro <[email protected]>
AuthorDate: Sun Feb 1 08:37:21 2026 +0100
AMQ-9854 Add wait for broker to process disconnect before publishing …
(#1646)
* AMQ-9854 Add wait for broker to process disconnect before publishing
messages in MQTTTest
* AMQ-9854 Fix MQTTTest to check for no active durable subscribers before
publishing messages after disconnect
---
.../org/apache/activemq/transport/mqtt/MQTTTest.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git
a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
index 7cf1523bee..743e8260bf 100644
---
a/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
+++
b/activemq-mqtt/src/test/java/org/apache/activemq/transport/mqtt/MQTTTest.java
@@ -1671,6 +1671,12 @@ public class MQTTTest extends MQTTTestSupport {
}
connectionSub.disconnect();
+ // Wait for broker to process disconnect before publishing messages
for offline delivery.
+ // Check for no active durable subscribers (works for both regular and
virtual topic strategies)
+ assertTrue("Subscription should become inactive",
+ Wait.waitFor(() ->
brokerService.getAdminView().getDurableTopicSubscribers().length == 0,
+ 5000, 100));
+
try {
for (int j = 0; j < numberOfRuns; j++) {
@@ -1690,6 +1696,11 @@ public class MQTTTest extends MQTTTestSupport {
message.ack();
}
connectionSub.disconnect();
+
+ // Wait for broker to process disconnect before next iteration
publishes
+ assertTrue("Subscription should become inactive",
+ Wait.waitFor(() ->
brokerService.getAdminView().getDurableTopicSubscribers().length == 0,
+ 5000, 100));
}
} catch (Exception exception) {
LOG.error("unexpected exception", exception);
@@ -1722,6 +1733,12 @@ public class MQTTTest extends MQTTTestSupport {
connectionSub.disconnect();
}
+ // Wait for broker to process disconnect before publishing messages
for offline delivery.
+ // Check for no active durable subscribers (works for both regular and
virtual topic strategies)
+ assertTrue("Subscription should become inactive",
+ Wait.waitFor(() ->
brokerService.getAdminView().getDurableTopicSubscribers().length == 0,
+ 5000, 100));
+
MQTT mqttPubLoop = createMQTTConnection("MQTT-Pub-Client", true);
BlockingConnection connectionPub = mqttPubLoop.blockingConnection();
connectionPub.connect();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact