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

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


The following commit(s) were added to refs/heads/main by this push:
     new a5d3f94224 Fix #6922 to add a JMS Component customizer if Artemis JMS 
RA is availiable (#6923)
a5d3f94224 is described below

commit a5d3f94224f81bfb6b1c2dcaa9348422ea2f2bb1
Author: Zheng Feng <zh.f...@gmail.com>
AuthorDate: Tue Jan 21 12:31:22 2025 +0800

    Fix #6922 to add a JMS Component customizer if Artemis JMS RA is availiable 
(#6923)
---
 .../component/jms/deployment/JmsProcessor.java     | 16 +++++++++
 .../quarkus/component/jms/CamelJmsRecorder.java    | 40 ++++++++++++++++++++++
 .../messaging/it/MessagingCommonRoutes.java        | 16 +--------
 3 files changed, 57 insertions(+), 15 deletions(-)

diff --git 
a/extensions/jms/deployment/src/main/java/org/apache/camel/quarkus/component/jms/deployment/JmsProcessor.java
 
b/extensions/jms/deployment/src/main/java/org/apache/camel/quarkus/component/jms/deployment/JmsProcessor.java
index d8de907803..d18cc95026 100644
--- 
a/extensions/jms/deployment/src/main/java/org/apache/camel/quarkus/component/jms/deployment/JmsProcessor.java
+++ 
b/extensions/jms/deployment/src/main/java/org/apache/camel/quarkus/component/jms/deployment/JmsProcessor.java
@@ -16,8 +16,13 @@
  */
 package org.apache.camel.quarkus.component.jms.deployment;
 
+import io.quarkus.deployment.annotations.BuildProducer;
 import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
 import io.quarkus.deployment.builditem.FeatureBuildItem;
+import org.apache.camel.quarkus.component.jms.CamelJmsRecorder;
+import 
org.apache.camel.quarkus.core.deployment.spi.CamelContextCustomizerBuildItem;
 import 
org.apache.camel.quarkus.core.deployment.spi.CamelSerializationBuildItem;
 
 class JmsProcessor {
@@ -33,4 +38,15 @@ class JmsProcessor {
     CamelSerializationBuildItem serialization() {
         return new CamelSerializationBuildItem();
     }
+
+    @BuildStep
+    @Record(ExecutionTime.STATIC_INIT)
+    void customizer(BuildProducer<CamelContextCustomizerBuildItem> 
customizers, CamelJmsRecorder recorder) {
+        try {
+            
Class.forName("org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl");
+            customizers.produce(new 
CamelContextCustomizerBuildItem(recorder.createCamelJmsCustomizer()));
+        } catch (ClassNotFoundException e) {
+            // Only create the JMS component customizer if the ActiveMQ 
Artemis RA is available
+        }
+    }
 }
diff --git 
a/extensions/jms/runtime/src/main/java/org/apache/camel/quarkus/component/jms/CamelJmsRecorder.java
 
b/extensions/jms/runtime/src/main/java/org/apache/camel/quarkus/component/jms/CamelJmsRecorder.java
new file mode 100644
index 0000000000..8bcccc90ac
--- /dev/null
+++ 
b/extensions/jms/runtime/src/main/java/org/apache/camel/quarkus/component/jms/CamelJmsRecorder.java
@@ -0,0 +1,40 @@
+/*
+ * 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.quarkus.component.jms;
+
+import io.quarkus.runtime.RuntimeValue;
+import io.quarkus.runtime.annotations.Recorder;
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.spi.CamelContextCustomizer;
+import org.apache.camel.spi.ComponentCustomizer;
+
+@Recorder
+public class CamelJmsRecorder {
+    public RuntimeValue<CamelContextCustomizer> createCamelJmsCustomizer() {
+        return new RuntimeValue<>(new CamelContextCustomizer() {
+            @Override
+            public void configure(CamelContext context) {
+                context.getRegistry().bind("jms-ra-customizer", 
ComponentCustomizer.forType(JmsComponent.class, component -> {
+                    component.setCacheLevelName("CACHE_NONE");
+                    component.setServiceLocationEnabled(false);
+                }));
+            }
+        });
+    }
+}
diff --git 
a/integration-tests-support/messaging/common/src/main/java/org/apache/camel/quarkus/component/messaging/it/MessagingCommonRoutes.java
 
b/integration-tests-support/messaging/common/src/main/java/org/apache/camel/quarkus/component/messaging/it/MessagingCommonRoutes.java
index 9ba2834031..084aa8b12d 100644
--- 
a/integration-tests-support/messaging/common/src/main/java/org/apache/camel/quarkus/component/messaging/it/MessagingCommonRoutes.java
+++ 
b/integration-tests-support/messaging/common/src/main/java/org/apache/camel/quarkus/component/messaging/it/MessagingCommonRoutes.java
@@ -41,12 +41,7 @@ public class MessagingCommonRoutes extends RouteBuilder {
         // The routes are later started in AbstractMessagingTest#beforeAll 
method
         camelContext.setAutoStartup(false);
 
-        String cacheLevel = "";
-        if (isCacheLevelNone()) {
-            cacheLevel = "&cacheLevelName=CACHE_NONE";
-        }
-
-        fromF("%s:queue:testJmsMessageType?concurrentConsumers=5%s", 
componentScheme, cacheLevel)
+        fromF("%s:queue:testJmsMessageType?concurrentConsumers=5", 
componentScheme)
                 .toF("%s:queue:testJmsMessageType2", componentScheme);
 
         String disableStreaming = "";
@@ -120,13 +115,4 @@ public class MessagingCommonRoutes extends RouteBuilder {
             return false;
         }
     }
-
-    private boolean isCacheLevelNone() {
-        try {
-            
Class.forName("org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl");
-            return !componentScheme.getScheme().startsWith("sjms");
-        } catch (ClassNotFoundException e) {
-            return false;
-        }
-    }
 }

Reply via email to