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 dfff671fdd (Fix/test) flaky testForceExpirationZeroOverrideDLQ in 
MessageInterceptorStrategyTest (#1852)
dfff671fdd is described below

commit dfff671fdda4ac457c7dbe8576193fc7e6d64889
Author: gurpartap3697 <[email protected]>
AuthorDate: Sun Mar 29 19:59:29 2026 +0530

    (Fix/test) flaky testForceExpirationZeroOverrideDLQ in 
MessageInterceptorStrategyTest (#1852)
    
    * Fix flakiness in 
MessageInterceptorStrategyTest#testForceExpirationZeroOverrideDLQ
    
    * use try-with-resources to close QueueBrowser instances
    
    * check if message reached DLQ in time
---
 .../broker/policy/MessageInterceptorStrategyTest.java   | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git 
a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageInterceptorStrategyTest.java
 
b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageInterceptorStrategyTest.java
index 5537037cb7..34a8fa6ead 100644
--- 
a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageInterceptorStrategyTest.java
+++ 
b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/policy/MessageInterceptorStrategyTest.java
@@ -38,6 +38,7 @@ import org.apache.activemq.broker.region.policy.PolicyEntry;
 import org.apache.activemq.broker.region.policy.PolicyMap;
 import org.apache.activemq.store.memory.MemoryPersistenceAdapter;
 import org.apache.activemq.test.TestSupport;
+import org.apache.activemq.util.Wait;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -207,7 +208,21 @@ public class MessageInterceptorStrategyTest extends 
TestSupport {
         Message sendMessageP = 
session.createTextMessage("expiration=zero-no-dlq-expiry");
         producer.send(queue, sendMessageP);
 
-        Thread.sleep(250l);
+        boolean reachedDlq = Wait.waitFor(new Wait.Condition() {
+            @Override
+            public boolean isSatisified() throws Exception {
+                boolean originalQueueEmpty;
+                boolean dlqHasMessage;
+                try (QueueBrowser originalBrowser = 
session.createBrowser(queue)) {
+                    originalQueueEmpty = 
!originalBrowser.getEnumeration().hasMoreElements();
+                }
+                try (QueueBrowser dlqBrowser = 
session.createBrowser(createQueue("mis.forceExpiration.zero-no-dlq-expiry.dlq")))
 {
+                    dlqHasMessage = 
dlqBrowser.getEnumeration().hasMoreElements();
+                }
+                return originalQueueEmpty && dlqHasMessage;
+            }
+        });
+        assertTrue("Message did not reach DLQ in time", reachedDlq);
 
         queueBrowser = session.createBrowser(queue);
         Enumeration<?> browseEnumeration = queueBrowser.getEnumeration();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to