This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-spring-boot-examples.git
commit a7ba33bfa4dccc314c6f153f05799017968fb2e1 Author: Zineb Bendhiba <bendhiba.zi...@gmail.com> AuthorDate: Thu Jul 23 10:33:54 2020 +0200 camel-arangodb-starter example --- README.adoc | 4 +- camel-example-spring-boot-arangodb/pom.xml | 88 ++++++++++++++++++++++ camel-example-spring-boot-arangodb/src/README.adoc | 50 ++++++++++++ .../example/springboot/arangodb/Application.java | 34 +++++++++ .../example/springboot/arangodb/CamelRoute.java | 37 +++++++++ .../example/springboot/arangodb/MyBeanService.java | 39 ++++++++++ .../src/main/resources/application.properties | 23 ++++++ pom.xml | 1 + 8 files changed, 275 insertions(+), 1 deletion(-) diff --git a/README.adoc b/README.adoc index 73d8d57..9c60131 100644 --- a/README.adoc +++ b/README.adoc @@ -11,7 +11,7 @@ View the individual example READMEs for details. == Examples // examples: START -Number of Examples: 40 (0 deprecated) +Number of Examples: 41 (0 deprecated) [width="100%",cols="4,2,4",options="header"] |=== @@ -51,6 +51,8 @@ Number of Examples: 40 (0 deprecated) | link:camel-example-spring-boot-master/readme.adoc[Spring Boot Master] (camel-example-spring-boot-master) | Clustering | An example showing how to work with Camel's Master component and Spring Boot +| link:camel-example-spring-boot-arangodb/readme.md[Spring Boot Arangodb] (camel-example-spring-boot-arangodb) | Database | An example showing the Camel ArangoDb component with Spring Boot + | link:camel-example-spring-boot-rest-jpa/README.adoc[Spring Boot REST JPA] (camel-example-spring-boot-rest-jpa) | Database | An example demonstrating how to use Camel REST DSL with JPA to expose a RESTful API that performs CRUD operations on a database diff --git a/camel-example-spring-boot-arangodb/pom.xml b/camel-example-spring-boot-arangodb/pom.xml new file mode 100644 index 0000000..1ab7b82 --- /dev/null +++ b/camel-example-spring-boot-arangodb/pom.xml @@ -0,0 +1,88 @@ +<?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>3.5.0-SNAPSHOT</version> + </parent> + + <artifactId>camel-example-spring-boot-arangodb</artifactId> + <name>Camel SB Examples :: ArangoDB</name> + <description>An example showing the Camel ArangoDb component with Spring Boot</description> + + <properties> + <category>Database</category> + <spring.boot-version>${spring-boot-version}</spring.boot-version> + </properties> + + <!-- Spring-Boot and Camel BOM --> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-dependencies</artifactId> + <version>${spring.boot-version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-spring-boot-dependencies</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <!-- Camel --> + <dependency> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-spring-boot-starter</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.springboot</groupId> + <artifactId>camel-arangodb-starter</artifactId> + </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> \ No newline at end of file diff --git a/camel-example-spring-boot-arangodb/src/README.adoc b/camel-example-spring-boot-arangodb/src/README.adoc new file mode 100644 index 0000000..4393239 --- /dev/null +++ b/camel-example-spring-boot-arangodb/src/README.adoc @@ -0,0 +1,50 @@ +== Spring Boot Example with ArangoDB + +=== Introduction + +This example demonstrates how you can use Camel-Arangodb Starter component. The example is really simple: put a document in the database and get the document with the same key. +You'll need a running ArangoDB server to run this example. + +=== Build + +You can build this example using: + + $ mvn package + +=== Run + +You can run this example following these steps using: + +Run an instance of ArangoDB with the root and password given in application.properties file. Example using the docker image : + + $ docker run -p 8529:8529 -e ARANGO_ROOT_PASSWORD=openSesame arangodb:latest + +Execute arangosh in your server. Example with the docker image ( set "openSesame" as password) + + $ docker exec -it <CONTAINER_ID> arangosh --server.username "root" + +Create the database "myDb" + + $ db._createDatabase("myDb") + +Create the collection "foo" + + $ db._useDatabase("myDb") + + $ db._create("foo") + +Run the app + + $ mvn spring-boot:run + +And you should see output in the console. You can also see the document created in the foo collection. + +=== 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/camel-example-spring-boot-arangodb/src/main/java/org/apache/camel/example/springboot/arangodb/Application.java b/camel-example-spring-boot-arangodb/src/main/java/org/apache/camel/example/springboot/arangodb/Application.java new file mode 100644 index 0000000..6b25ccb --- /dev/null +++ b/camel-example-spring-boot-arangodb/src/main/java/org/apache/camel/example/springboot/arangodb/Application.java @@ -0,0 +1,34 @@ +/* + * 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.example.springboot.arangodb; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +// CHECKSTYLE:OFF +@SpringBootApplication +public class Application { + + /** + * Main method to start the application. + */ + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} +// CHECKSTYLE:ON diff --git a/camel-example-spring-boot-arangodb/src/main/java/org/apache/camel/example/springboot/arangodb/CamelRoute.java b/camel-example-spring-boot-arangodb/src/main/java/org/apache/camel/example/springboot/arangodb/CamelRoute.java new file mode 100644 index 0000000..ed58b37 --- /dev/null +++ b/camel-example-spring-boot-arangodb/src/main/java/org/apache/camel/example/springboot/arangodb/CamelRoute.java @@ -0,0 +1,37 @@ +/* + * 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.example.springboot.arangodb; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.arangodb.ArangoDbConstants; +import org.springframework.stereotype.Component; + +@Component +public class CamelRoute extends RouteBuilder { + + @Override + public void configure() throws Exception { + + from("timer://foo?period=10000&repeatCount=1") + .bean(MyBeanService.class, "createDocument") + .to("arangodb:myDb?operation=SAVE_DOCUMENT") + .bean(MyBeanService.class, "readDocument") + .setHeader(ArangoDbConstants.RESULT_CLASS_TYPE).constant(String.class) + .to("arangodb:myDb?operation=FIND_DOCUMENT_BY_KEY") + .log("Received body: ${body}"); + } +} diff --git a/camel-example-spring-boot-arangodb/src/main/java/org/apache/camel/example/springboot/arangodb/MyBeanService.java b/camel-example-spring-boot-arangodb/src/main/java/org/apache/camel/example/springboot/arangodb/MyBeanService.java new file mode 100644 index 0000000..1838117 --- /dev/null +++ b/camel-example-spring-boot-arangodb/src/main/java/org/apache/camel/example/springboot/arangodb/MyBeanService.java @@ -0,0 +1,39 @@ +/* + * 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.example.springboot.arangodb; + +import com.arangodb.entity.BaseDocument; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +@Component +public class MyBeanService { + + private static final String KEY = "key1"; + + public BaseDocument createDocument() { + BaseDocument document = new BaseDocument(); + document.setKey(KEY); + document.addAttribute("foo", "bar"); + return document; + } + + public String readDocument() { + return KEY; + } + +} diff --git a/camel-example-spring-boot-arangodb/src/main/resources/application.properties b/camel-example-spring-boot-arangodb/src/main/resources/application.properties new file mode 100644 index 0000000..e5f5df2 --- /dev/null +++ b/camel-example-spring-boot-arangodb/src/main/resources/application.properties @@ -0,0 +1,23 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +camel.springboot.name=ArangoDB +camel.springboot.main-run-controller=true +camel.component.arangodb.collection=foo +camel.component.arangodb.user=root +camel.component.arangodb.password=openSesame + + diff --git a/pom.xml b/pom.xml index 5ada0c5..948a524 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,7 @@ <module>camel-example-spring-boot</module> <module>camel-example-spring-boot-activemq</module> <module>camel-example-spring-boot-amqp</module> + <module>camel-example-spring-boot-arangodb</module> <module>camel-example-spring-boot-clustered-route-controller</module> <module>camel-example-spring-boot-fhir</module> <module>camel-example-spring-boot-fhir-auth-tx</module>