You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/02/09 05:28:49 UTC

[camel] branch main updated: Artemis Priority Tests (#9314)

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 53d6bb2f505 Artemis Priority Tests (#9314)
53d6bb2f505 is described below

commit 53d6bb2f505e200ae97230c129fb3c4a94624733
Author: Federico Mariani <34...@users.noreply.github.com>
AuthorDate: Thu Feb 9 06:28:41 2023 +0100

    Artemis Priority Tests (#9314)
---
 .../component/jms/JmsPriorityConsumerTest.java     | 77 ++++++++++++++++++++++
 .../component/jms/TwoConsumerOnSameQueueTest.java  |  1 +
 2 files changed, 78 insertions(+)

diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsPriorityConsumerTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsPriorityConsumerTest.java
new file mode 100644
index 00000000000..f10bfb79490
--- /dev/null
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsPriorityConsumerTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class JmsPriorityConsumerTest extends AbstractJMSTest {
+
+    @Override
+    protected String getComponentName() {
+        return "jms";
+    }
+
+    @Test
+    public void testPriority() throws Exception {
+        int messages = 100;
+
+        ExecutorService executor = Executors.newFixedThreadPool(5);
+        for (int i = 0; i < messages; i++) {
+            final int index = i;
+            executor.submit(() -> {
+                template.sendBody("jms:queue:JmsPriorityConsumerTest", "Message " + index);
+                return null;
+            });
+        }
+
+        executor.awaitTermination(5, TimeUnit.SECONDS);
+
+        MockEndpoint lowPriority = getMockEndpoint("mock:lowPriority");
+        MockEndpoint mediumPriority = getMockEndpoint("mock:mediumPriority");
+        MockEndpoint highPriority = getMockEndpoint("mock:highPriority");
+
+        Assertions.assertThat(highPriority.getReceivedExchanges().size())
+                .isGreaterThan(mediumPriority.getReceivedExchanges().size());
+
+        Assertions.assertThat(mediumPriority.getReceivedExchanges().size())
+                .isGreaterThanOrEqualTo(lowPriority.getReceivedExchanges().size());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("jms:queue:JmsPriorityConsumerTest?artemisConsumerPriority=1")
+                        .to("mock:lowPriority");
+
+                from("jms:queue:JmsPriorityConsumerTest?artemisConsumerPriority=4")
+                        .to("mock:mediumPriority");
+
+                from("jms:queue:JmsPriorityConsumerTest?artemisConsumerPriority=9")
+                        .to("mock:highPriority");
+            }
+        };
+    }
+}
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 0be72a09ea2..4a114298f50 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
@@ -36,6 +36,7 @@ public class TwoConsumerOnSameQueueTest extends AbstractPersistentJMSTest {
     }
 
     @Test
+    @DisabledIfSystemProperty(named = "ci.env.name", matches = "github.com", disabledReason = "Flaky on Github CI")
     public void testStopAndStartOneRoute() throws Exception {
         sendTwoMessagesWhichShouldReceivedOnBothEndpointsAndAssert();