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

nfilotto pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot-examples.git


The following commit(s) were added to refs/heads/main by this push:
     new f9f4a88  CAMEL-19341:camel-spring-boot - Example with ActiveMQ Artemis 
(#110)
f9f4a88 is described below

commit f9f4a88422c90645472ea1fa18cdfa548990288e
Author: Ramu <kramu...@gmail.com>
AuthorDate: Thu Jun 15 14:35:01 2023 +0530

    CAMEL-19341:camel-spring-boot - Example with ActiveMQ Artemis (#110)
---
 artemis/pom.xml                                    | 129 +++++++++++++++++++++
 artemis/readme.adoc                                |  24 ++++
 artemis/src/main/data/readme.adoc                  |   4 +
 .../java/sample/camel/SampleAmqApplication.java    |  31 +++++
 .../src/main/java/sample/camel/SampleJmsRoute.java |  35 ++++++
 artemis/src/main/resources/application.properties  |  27 +++++
 .../sample/camel/SampleAmqApplicationTests.java    |  40 +++++++
 pom.xml                                            |   2 +
 8 files changed, 292 insertions(+)

diff --git a/artemis/pom.xml b/artemis/pom.xml
new file mode 100644
index 0000000..8c8d460
--- /dev/null
+++ b/artemis/pom.xml
@@ -0,0 +1,129 @@
+<?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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel.springboot.example</groupId>
+        <artifactId>examples</artifactId>
+        <version>4.0.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-example-spring-boot-artemis</artifactId>
+    <name>Camel SB Examples :: artemis</name>
+    <description>An example showing how to work with Camel, ActiveMQ Artemis 
and Spring Boot</description>
+
+    <properties>
+        <category>Messaging</category>
+
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+    </properties>
+
+    <dependencyManagement>
+
+        <dependencies>
+            <!-- Spring Boot BOM -->
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${spring-boot-version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+
+            <!-- Camel BOM -->
+            <dependency>
+                <groupId>org.apache.camel.springboot</groupId>
+                <artifactId>camel-spring-boot-bom</artifactId>
+                <version>${project.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+
+    </dependencyManagement>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-artemis</artifactId>
+        </dependency>
+
+        <!-- Camel -->
+        <dependency>
+            <groupId>org.apache.camel.springboot</groupId>
+            <artifactId>camel-spring-boot-starter</artifactId>
+        </dependency>
+
+          <!-- Add the Artemis jakarta client library which will include the 
ActiveMQConnectionFactory -->
+        <dependency>
+            <groupId>org.apache.activemq</groupId>
+            <artifactId>artemis-jakarta-client</artifactId>
+            <version>${artemis-jakarta-version}</version> 
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.activemq</groupId>
+            <artifactId>artemis-jakarta-server</artifactId>
+            <version>${artemis-jakarta-version}</version>
+        </dependency> 
+               
+        <dependency>
+            <groupId>org.apache.camel.springboot</groupId>
+            <artifactId>camel-jms-starter</artifactId>
+        </dependency>
+       
+        <!-- test -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test-spring-junit5</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>${spring-boot-version}</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/artemis/readme.adoc b/artemis/readme.adoc
new file mode 100644
index 0000000..21fb33c
--- /dev/null
+++ b/artemis/readme.adoc
@@ -0,0 +1,24 @@
+== Camel Example Spring Boot and ActiveMQ Artemis
+
+This example shows how to work with a simple Apache Camel application using 
Spring Boot and Apache ActiveMQ Artemis.
+
+=== How to run the example
+
+You can run this example using
+
+    mvn spring-boot:run
+
+=== Using Camel components
+
+Apache Camel provides 200+ components which you can use to integrate and route 
messages between many systems
+and data formats. To use any of these Camel components, add the component as a 
dependency to your project.
+
+=== Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+https://camel.apache.org/support.html[let us know].
+
+We also love contributors, so
+https://camel.apache.org/contributing.html[get involved] :-)
+
+The Camel riders!
diff --git a/artemis/src/main/data/readme.adoc 
b/artemis/src/main/data/readme.adoc
new file mode 100644
index 0000000..daee351
--- /dev/null
+++ b/artemis/src/main/data/readme.adoc
@@ -0,0 +1,4 @@
+
+== Camel Example Spring Boot and ActiveMQ Artemis ==
+The APACHE Camel riders!
+
diff --git a/artemis/src/main/java/sample/camel/SampleAmqApplication.java 
b/artemis/src/main/java/sample/camel/SampleAmqApplication.java
new file mode 100644
index 0000000..fe312d6
--- /dev/null
+++ b/artemis/src/main/java/sample/camel/SampleAmqApplication.java
@@ -0,0 +1,31 @@
+/*
+ * 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 sample.camel;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+//CHECKSTYLE:OFF
+@SpringBootApplication
+@EnableAutoConfiguration
+public class SampleAmqApplication {
+    public static void main(String[] args) {
+        SpringApplication.run(SampleAmqApplication.class, args);
+    }
+}
+// CHECKSTYLE:ON
diff --git a/artemis/src/main/java/sample/camel/SampleJmsRoute.java 
b/artemis/src/main/java/sample/camel/SampleJmsRoute.java
new file mode 100644
index 0000000..a184233
--- /dev/null
+++ b/artemis/src/main/java/sample/camel/SampleJmsRoute.java
@@ -0,0 +1,35 @@
+/*
+ * 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 sample.camel;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SampleJmsRoute extends RouteBuilder {
+       
+    @Override
+    public void configure() throws Exception {
+
+        from("file:src/main/data?noop=true")
+            .to("jms:queue:{{spring.artemis.embedded.queue}}");
+
+       
+        from("jms:queue:{{spring.artemis.embedded.queue}}")
+            .log("${body}");
+    }
+}
\ No newline at end of file
diff --git a/artemis/src/main/resources/application.properties 
b/artemis/src/main/resources/application.properties
new file mode 100644
index 0000000..fb8fd19
--- /dev/null
+++ b/artemis/src/main/resources/application.properties
@@ -0,0 +1,27 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#You can use this property to override the default autowired broker-url
+camel.springboot.main-run-controller = true
+#spring.artemis.mode=native
+spring.artemis.mode=embedded
+spring.artemis.host=localhost
+spring.artemis.port=61616
+spring.artemis.user=test
+spring.artemis.password=test
+spring.artemis.embedded.enabled=true
+spring.artemis.embedded.queue=SCIENCEQUEUE
\ No newline at end of file
diff --git a/artemis/src/test/java/sample/camel/SampleAmqApplicationTests.java 
b/artemis/src/test/java/sample/camel/SampleAmqApplicationTests.java
new file mode 100644
index 0000000..9689292
--- /dev/null
+++ b/artemis/src/test/java/sample/camel/SampleAmqApplicationTests.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 sample.camel;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.NotifyBuilder;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@CamelSpringBootTest
+@SpringBootTest(classes = SampleAmqApplication.class)
+public class SampleAmqApplicationTests {
+    @Autowired
+    private CamelContext camelContext;
+
+    @Test
+    public void shouldProduceMessages() throws Exception {
+        NotifyBuilder notify = new 
NotifyBuilder(camelContext).whenDone(1).create();
+        assertTrue(notify.matches(10, TimeUnit.SECONDS));
+    }
+}
diff --git a/pom.xml b/pom.xml
index 29bd6d9..5fadca7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -39,6 +39,7 @@
                <module>actuator-http-metrics</module>
                <module>amqp</module>
                <module>arangodb</module>
+                <module>artemis</module>  
                <module>aws-secrets-manager</module>
                <module>aws2-s3</module>
                <module>dynamic-router-eip</module>
@@ -95,6 +96,7 @@
                <testcontainers-version>1.16.3</testcontainers-version>
                <hapi-structures-v24-version>2.3</hapi-structures-v24-version>
                
<narayana-spring-boot-version>2.6.3</narayana-spring-boot-version>
+                <artemis-jakarta-version>2.28.0</artemis-jakarta-version>
        </properties>
 
        <repositories>

Reply via email to