You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2024/03/01 12:54:25 UTC

(camel) branch main updated (46c7ae5d42e -> 9dc039f4429)

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 46c7ae5d42e Update camel-4x-upgrade-guide-4_4.adoc
     new d09751438e9 CAMEL-20477: TwoConsumerOnSameQueueTest needs an exclusive broker and context
     new df36d1609da CAMEL-20477: avoid sharing reply queues
     new 9dc039f4429 CAMEL-20477: split flaky transacted test

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../component/jms/TwoConsumerOnSameQueueTest.java  | 28 +++++++-
 .../spring/tx/JMSTXInOutPersistentQueueIT.java     |  3 +-
 .../spring/tx/JmsToJmsTransactedIT.java            | 43 +++---------
 .../tx/JmsToJmsTransactedMarkRollbackIT.java       | 79 ++++++++++++++++++++++
 .../issues/JmsInOutPersistentReplyQueueTest.java   |  3 +-
 ...IT.xml => JmsToJmsTransactedMarkRollbackIT.xml} |  2 +-
 6 files changed, 119 insertions(+), 39 deletions(-)
 create mode 100644 components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedMarkRollbackIT.java
 copy components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/{JmsToJmsTransactedIT.xml => JmsToJmsTransactedMarkRollbackIT.xml} (96%)


(camel) 02/03: CAMEL-20477: avoid sharing reply queues

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit df36d1609dafb461abb6dd5fadc6929ad9870b9c
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Fri Mar 1 11:23:55 2024 +0100

    CAMEL-20477: avoid sharing reply queues
---
 .../jms/integration/spring/tx/JMSTXInOutPersistentQueueIT.java         | 3 ++-
 .../camel/component/jms/issues/JmsInOutPersistentReplyQueueTest.java   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JMSTXInOutPersistentQueueIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JMSTXInOutPersistentQueueIT.java
index 7e45e6f375e..b631e1a76fd 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JMSTXInOutPersistentQueueIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JMSTXInOutPersistentQueueIT.java
@@ -70,7 +70,8 @@ public class JMSTXInOutPersistentQueueIT extends AbstractSpringJMSITSupport {
         return new RouteBuilder() {
             @Override
             public void configure() {
-                from("direct:start").to(ExchangePattern.InOut, "activemq:queue:JMSTXInOutPersistentQueueTest?replyTo=myReplies")
+                from("direct:start").to(ExchangePattern.InOut,
+                        "activemq:queue:JMSTXInOutPersistentQueueTest?replyTo=JmsInOutPersistentReplyQueueTest.myReplies")
                         .to("mock:reply")
                         .process(exchange -> {
                             if (counter++ < 2) {
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutPersistentReplyQueueTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutPersistentReplyQueueTest.java
index 1c137405697..a93141b7132 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutPersistentReplyQueueTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsInOutPersistentReplyQueueTest.java
@@ -66,7 +66,8 @@ public class JmsInOutPersistentReplyQueueTest extends AbstractJMSTest {
             public void configure() {
                 from("seda:start")
                         .log("Sending ${body}")
-                        .to(ExchangePattern.InOut, "activemq:queue:JmsInOutPersistentReplyQueueTest?replyTo=myReplies")
+                        .to(ExchangePattern.InOut,
+                                "activemq:queue:JmsInOutPersistentReplyQueueTest?replyTo=JmsInOutPersistentReplyQueueTest.myReplies")
                         // process the remainder of the route concurrently
                         .threads(5)
                         .log("Reply ${body}")


(camel) 03/03: CAMEL-20477: split flaky transacted test

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 9dc039f4429a25e1d469955de9c60f414e7d0a62
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Fri Mar 1 12:47:27 2024 +0100

    CAMEL-20477: split flaky transacted test
---
 .../spring/tx/JmsToJmsTransactedIT.java            | 43 +++---------
 .../tx/JmsToJmsTransactedMarkRollbackIT.java       | 79 ++++++++++++++++++++++
 .../spring/tx/JmsToJmsTransactedMarkRollbackIT.xml | 56 +++++++++++++++
 3 files changed, 143 insertions(+), 35 deletions(-)

diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedIT.java
index 348c1cc64cc..10591e5451c 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedIT.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedIT.java
@@ -21,11 +21,13 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.infra.artemis.services.ArtemisService;
 import org.apache.camel.test.infra.artemis.services.ArtemisServiceFactory;
 import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
-import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
 import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Tags;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestMethodOrder;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
@@ -33,8 +35,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 
 @TestInstance(TestInstance.Lifecycle.PER_METHOD)
 @Tags({ @Tag("not-parallel"), @Tag("spring"), @Tag("tx") })
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
 public final class JmsToJmsTransactedIT extends CamelSpringTestSupport {
 
+    @Order(0)
     @RegisterExtension
     public static ArtemisService service = ArtemisServiceFactory.createVMService();
 
@@ -47,18 +51,13 @@ public final class JmsToJmsTransactedIT extends CamelSpringTestSupport {
         return service.serviceAddress();
     }
 
-    @BeforeEach
-    public void beforeEach() {
-        service.shutdown();
-        service.initialize();
-    }
-
     @Override
     protected ClassPathXmlApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext(
                 "/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedIT.xml");
     }
 
+    @Order(1)
     @Test
     public void testJmsToJmsTestOK() throws Exception {
         context.addRoutes(new RouteBuilder() {
@@ -77,6 +76,7 @@ public final class JmsToJmsTransactedIT extends CamelSpringTestSupport {
         assertEquals("Hello World", reply);
     }
 
+    @Order(2)
     @Test
     public void testJmsToJmsTestRollbackDueToException() throws Exception {
         context.addRoutes(new RouteBuilder() {
@@ -104,6 +104,7 @@ public final class JmsToJmsTransactedIT extends CamelSpringTestSupport {
         MockEndpoint.assertIsSatisfied(context);
     }
 
+    @Order(3)
     @Test
     public void testJmsToJmsTestRollbackDueToRollback() throws Exception {
         context.addRoutes(new RouteBuilder() {
@@ -134,32 +135,4 @@ public final class JmsToJmsTransactedIT extends CamelSpringTestSupport {
         Object body = consumer.receiveBody("activemq:queue:DLQ", 2000);
         assertEquals("Hello World", body);
     }
-
-    @Test
-    public void testJmsToJmsTestRollbackDueToMarkRollbackOnly() throws Exception {
-        context.addRoutes(new RouteBuilder() {
-            @Override
-            public void configure() {
-                from("activemq:queue:JmsToJmsTransactedIT")
-                        .transacted()
-                        .to("mock:start")
-                        .to("activemq:queue:JmsToJmsTransactedIT.reply")
-                        .markRollbackOnly();
-
-                from("activemq:queue:JmsToJmsTransactedIT.reply").to("log:bar").to("mock:bar");
-            }
-        });
-        context.start();
-
-        MockEndpoint bar = getMockEndpoint("mock:bar");
-        bar.expectedMessageCount(0);
-
-        MockEndpoint start = getMockEndpoint("mock:start");
-        start.expectedMessageCount(7); // default number of redeliveries by AMQ is 6 so we get 6+1
-
-        template.sendBody("activemq:queue:JmsToJmsTransactedIT", "Hello World");
-
-        MockEndpoint.assertIsSatisfied(context);
-    }
-
 }
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedMarkRollbackIT.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedMarkRollbackIT.java
new file mode 100644
index 00000000000..b69c53ca0b6
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedMarkRollbackIT.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jms.integration.spring.tx;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.artemis.services.ArtemisService;
+import org.apache.camel.test.infra.artemis.services.ArtemisServiceFactory;
+import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
+import org.junit.jupiter.api.Order;
+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.ClassPathXmlApplicationContext;
+
+@Tags({ @Tag("not-parallel"), @Tag("spring"), @Tag("tx") })
+public final class JmsToJmsTransactedMarkRollbackIT extends CamelSpringTestSupport {
+
+    @Order(0)
+    @RegisterExtension
+    public static ArtemisService service = ArtemisServiceFactory.createVMService();
+
+    /**
+     * Used by spring xml configurations
+     *
+     * @return
+     */
+    public static String getServiceAddress() {
+        return service.serviceAddress();
+    }
+
+    @Override
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext(
+                "/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedMarkRollbackIT.xml");
+    }
+
+    @Test
+    public void testJmsToJmsTestRollbackDueToMarkRollbackOnly() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("activemq:queue:JmsToJmsTransactedMarkRollbackIT")
+                        .transacted()
+                        .to("mock:start")
+                        .to("activemq:queue:JmsToJmsTransactedMarkRollbackIT.reply")
+                        .markRollbackOnly();
+
+                from("activemq:queue:JmsToJmsTransactedMarkRollbackIT.reply").to("log:bar").to("mock:bar");
+            }
+        });
+        context.start();
+
+        MockEndpoint bar = getMockEndpoint("mock:bar");
+        bar.expectedMessageCount(0);
+
+        MockEndpoint start = getMockEndpoint("mock:start");
+        start.expectedMessageCount(7); // default number of redeliveries by AMQ is 6 so we get 6+1
+
+        template.sendBody("activemq:queue:JmsToJmsTransactedMarkRollbackIT", "Hello World");
+
+        MockEndpoint.assertIsSatisfied(context);
+    }
+}
diff --git a/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedMarkRollbackIT.xml b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedMarkRollbackIT.xml
new file mode 100644
index 00000000000..ea308535586
--- /dev/null
+++ b/components/camel-jms/src/test/resources/org/apache/camel/component/jms/integration/spring/tx/JmsToJmsTransactedMarkRollbackIT.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xsi:schemaLocation="
+         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+         http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+    <bean id="poolConnectionFactory" class="org.messaginghub.pooled.jms.JmsPoolConnectionFactory" init-method="start" destroy-method="stop">
+        <property name="maxConnections" value="8"/>
+        <property name="connectionFactory" ref="jmsConnectionFactory"/>
+    </bean>
+
+    <bean id="jmsConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
+        <property name="brokerURL">
+            <bean class="org.apache.camel.component.jms.integration.spring.tx.JmsToJmsTransactedMarkRollbackIT" factory-method="getServiceAddress"/>
+        </property>
+    </bean>
+
+    <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
+        <property name="connectionFactory" ref="poolConnectionFactory"/>
+    </bean>
+
+    <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">
+        <property name="connectionFactory" ref="poolConnectionFactory"/>
+        <property name="transacted" value="true"/>
+        <property name="transactionManager" ref="jmsTransactionManager"/>
+    </bean>
+
+    <bean id="activemq2" class="org.apache.camel.component.jms.JmsComponent">
+    <property name="connectionFactory">
+       <bean class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
+        <property name="brokerURL" value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
+       </bean>
+    </property>
+    </bean>
+
+</beans>


(camel) 01/03: CAMEL-20477: TwoConsumerOnSameQueueTest needs an exclusive broker and context

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit d09751438e9889207b3111a3879e3d4290bc610b
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Fri Mar 1 11:21:35 2024 +0100

    CAMEL-20477: TwoConsumerOnSameQueueTest needs an exclusive broker and context
---
 .../component/jms/TwoConsumerOnSameQueueTest.java  | 28 +++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/TwoConsumerOnSameQueueTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/TwoConsumerOnSameQueueTest.java
index a142011ae43..2fa7d237ca4 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/TwoConsumerOnSameQueueTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/TwoConsumerOnSameQueueTest.java
@@ -18,9 +18,16 @@ package org.apache.camel.component.jms;
 
 import java.util.concurrent.TimeUnit;
 
+import jakarta.jms.ConnectionFactory;
+
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.infra.artemis.common.ConnectionFactoryHelper;
+import org.apache.camel.test.infra.artemis.services.ArtemisService;
+import org.apache.camel.test.infra.artemis.services.ArtemisServiceFactory;
+import org.apache.camel.test.junit5.CamelTestSupport;
 import org.awaitility.Awaitility;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Tag;
@@ -28,14 +35,33 @@ import org.junit.jupiter.api.Tags;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.TestInstance;
 import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 @Tags({ @Tag("not-parallel") })
 @TestInstance(TestInstance.Lifecycle.PER_METHOD)
-public class TwoConsumerOnSameQueueTest extends AbstractPersistentJMSTest {
+public class TwoConsumerOnSameQueueTest extends CamelTestSupport {
+
+    @RegisterExtension
+    public static ArtemisService service = ArtemisServiceFactory.createPersistentVMService();
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+
+        createConnectionFactory(camelContext);
+
+        return camelContext;
+    }
+
+    protected void createConnectionFactory(CamelContext camelContext) {
+        ConnectionFactory connectionFactory = ConnectionFactoryHelper.createConnectionFactory(service);
+        camelContext.addComponent("activemq", jmsComponentAutoAcknowledge(connectionFactory));
+    }
 
     @Test
     public void testTwoConsumerOnSameQueue() throws Exception {