You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2026/07/30 13:31:59 UTC
(camel) 01/01: chore: add diagnostic error handler to IBM MQ reply-to test
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch fix/ibmmq-10-upgrade-with-lang-fix
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6b3d1d8aa936270f46cdae18973f23a574329dff
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Thu Jul 30 15:31:43 2026 +0200
chore: add diagnostic error handler to IBM MQ reply-to test
Capture the actual exception thrown during reply sending that is
normally swallowed by Spring DMLC's error handler. This will reveal
why JmsReplyToIbmMQTest.testCustomJMSReplyToInOut fails with MQ 10.0.
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
.../component/jms/issues/JmsReplyToIbmMQTest.java | 38 ++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsReplyToIbmMQTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsReplyToIbmMQTest.java
index e8f246898327..9f68d129d142 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsReplyToIbmMQTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsReplyToIbmMQTest.java
@@ -16,10 +16,15 @@
*/
package org.apache.camel.component.jms.issues;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
import jakarta.jms.ConnectionFactory;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.component.jms.JmsTestHelper;
import org.apache.camel.test.infra.ibmmq.common.ConnectionFactoryHelper;
import org.apache.camel.test.infra.ibmmq.services.IbmMQService;
@@ -28,24 +33,45 @@ import org.apache.camel.test.junit6.CamelTestSupport;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.extension.RegisterExtension;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
@DisabledOnOs(architectures = { "aarch64", "aarch_64" }, disabledReason = "IBM MQ has no Linux ARM64 native image")
public class JmsReplyToIbmMQTest extends CamelTestSupport {
+ private static final Logger LOG = LoggerFactory.getLogger(JmsReplyToIbmMQTest.class);
+
@RegisterExtension
public static IbmMQService service = IbmMQServiceFactory.createService();
+ // Captures any error thrown during reply sending (normally swallowed by Spring DMLC)
+ private final AtomicReference<Throwable> listenerError = new AtomicReference<>();
+ private final CountDownLatch errorLatch = new CountDownLatch(1);
+
@Test
- public void testCustomJMSReplyToInOut() {
+ public void testCustomJMSReplyToInOut() throws Exception {
JmsTestHelper.waitForJmsConsumerRoutes(context, "request");
template.sendBody("jms:queue:DEV.QUEUE.1", "What is your name?");
String reply
= consumer.receiveBody("jms:queue:DEV.QUEUE.2", 20000, String.class);
+
+ if (reply == null) {
+ // Check if the listener error handler captured an exception
+ if (errorLatch.await(2, TimeUnit.SECONDS)) {
+ Throwable error = listenerError.get();
+ LOG.error("Reply was null — listener error handler captured exception", error);
+ fail("Reply was null. Listener error: " + error, error);
+ } else {
+ fail("Reply was null and no listener error was captured within timeout");
+ }
+ }
+
assertEquals("My name is Camel", reply);
}
@@ -68,7 +94,15 @@ public class JmsReplyToIbmMQTest extends CamelTestSupport {
ConnectionFactory connectionFactory
= ConnectionFactoryHelper.createConnectionFactory(
service.queueManager(), service.channel(), service.listenerPort());
- camelContext.addComponent("jms", jmsComponentAutoAcknowledge(connectionFactory));
+ JmsComponent jms = jmsComponentAutoAcknowledge(connectionFactory);
+ // Install a custom error handler to capture the actual exception
+ // instead of Spring DMLC silently logging it
+ jms.getConfiguration().setErrorHandler(t -> {
+ LOG.error("MSQ MQ JMS error handler caught exception during message processing", t);
+ listenerError.set(t);
+ errorLatch.countDown();
+ });
+ camelContext.addComponent("jms", jms);
return camelContext;
}
}