This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 533ca6b28aa7 CAMEL-27555: Fix flaky test JMSTransactionRollbackIT
(#30882)
533ca6b28aa7 is described below
commit 533ca6b28aa72924dc84ea1ad48b44966abb2975
Author: Guillaume Nodet <[email protected]>
AuthorDate: Thu Nov 26 21:07:50 2026 +0100
CAMEL-27555: Fix flaky test JMSTransactionRollbackIT (#30882)
The test asserts expectedMessageCount(6) on mock:before (1 initial
delivery + 5 redeliveries), but the shared Artemis singleton broker
uses the default maxDeliveryAttempts=10. On fast machines the latch
releases at 6 then more broker redeliveries arrive (Expected 6 but
was 8/10); on slow CI the wait window closes before all 6 arrive
(Expected 6 but was 5).
Fix: give the test its own dedicated Artemis broker configured with
maxDeliveryAttempts=6, so the broker stops redelivering exactly when
the test expects. Add setAssertPeriod(2000) on mock:before to guard
against late-arriving extra messages after the count is satisfied.
Update the Spring XML to call JMSTransactionRollbackIT.getServiceAddress()
instead of AbstractSpringJMSITSupport.getServiceAddress() since the
test no longer extends that class.
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
---
.../spring/tx/error/JMSTransactionRollbackIT.java | 44 ++++++++++++++++++++--
.../spring/tx/error/JMSTransactionRollbackIT.xml | 2 +-
2 files changed, 41 insertions(+), 5 deletions(-)
diff --git
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/error/JMSTransactionRollbackIT.java
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/error/JMSTransactionRollbackIT.java
index 8ae0459b65af..6afb0ca94723 100644
---
a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/error/JMSTransactionRollbackIT.java
+++
b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/error/JMSTransactionRollbackIT.java
@@ -16,25 +16,61 @@
*/
package org.apache.camel.component.jms.integration.spring.tx.error;
-import
org.apache.camel.component.jms.integration.spring.AbstractSpringJMSITSupport;
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.camel.component.mock.MockEndpoint;
+import
org.apache.camel.test.infra.artemis.services.ArtemisEmbeddedServiceBuilder;
+import org.apache.camel.test.infra.artemis.services.ArtemisService;
+import org.apache.camel.test.spring.junit6.CamelSpringTestSupport;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Tags;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@Tags({ @Tag("not-parallel"), @Tag("spring"), @Tag("tx") })
-public class JMSTransactionRollbackIT extends AbstractSpringJMSITSupport {
+public class JMSTransactionRollbackIT extends CamelSpringTestSupport {
+
+ // Use a dedicated broker with maxDeliveryAttempts=6 (1 initial + 5
retries) to match the
+ // test's expectedMessageCount(6). The shared singleton broker defaults to
maxDeliveryAttempts=10,
+ // causing extra redeliveries that make the mock fail with "Expected 6 but
was 8/10" on fast
+ // machines, or "Expected 6 but was 5" on slow CI when the latch releases
early.
+ @RegisterExtension
+ public static ArtemisService service = new ArtemisEmbeddedServiceBuilder()
+ .withCustomConfiguration(configuration -> {
+ AddressSettings addressSettings = new AddressSettings()
+
.setAddressFullMessagePolicy(AddressFullMessagePolicy.FAIL)
+ .setAutoDeleteQueues(false)
+ .setDeadLetterAddress(SimpleString.of("DLQ"))
+ .setExpiryAddress(SimpleString.of("ExpiryQueue"))
+ .setMaxDeliveryAttempts(6);
+ configuration.addAddressSetting("#", addressSettings);
+ })
+ .build();
+
+ /**
+ * Used by the Spring XML context to obtain the broker address.
+ *
+ * @return the service address
+ */
+ public static String getServiceAddress() {
+ return service.serviceAddress();
+ }
@Override
- protected ClassPathXmlApplicationContext createApplicationContext() {
+ protected AbstractApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext(
"/org/apache/camel/component/jms/integration/spring/tx/error/JMSTransactionRollbackIT.xml");
}
@Test
public void testTransactionRollback() throws Exception {
- getMockEndpoint("mock:before").expectedMessageCount(6);
+ MockEndpoint before = getMockEndpoint("mock:before");
+ before.expectedMessageCount(6);
+ // Guard against late-arriving extra broker redeliveries on fast
machines
+ before.setAssertPeriod(2000);
getMockEndpoint("mock:result").expectedMessageCount(0);
template.sendBody("activemq:queue:okay.JMSTransactionRollbackTest",
"Hello World");
diff --git
a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/error/JMSTransactionRollbackIT.xml
b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/error/JMSTransactionRollbackIT.xml
index 5870cc28eeee..21d8155121c8 100644
---
a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/error/JMSTransactionRollbackIT.xml
+++
b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/error/JMSTransactionRollbackIT.xml
@@ -31,7 +31,7 @@
<bean id="jmsConnectionFactory"
class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
<property name="brokerURL">
- <bean
class="org.apache.camel.component.jms.integration.spring.AbstractSpringJMSITSupport"
factory-method="getServiceAddress"/>
+ <bean
class="org.apache.camel.component.jms.integration.spring.tx.error.JMSTransactionRollbackIT"
factory-method="getServiceAddress"/>
</property>
</bean>