You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2017/08/01 06:43:47 UTC
camel git commit: CAMEL-11618 - Add a Camel-Infinispan example using
his starter
Repository: camel
Updated Branches:
refs/heads/master b3f63b4cf -> b45826875
CAMEL-11618 - Add a Camel-Infinispan example using his starter
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b4582687
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b4582687
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b4582687
Branch: refs/heads/master
Commit: b4582687516b09078a0a3dc198e70b7938ce900c
Parents: b3f63b4
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Aug 1 08:39:34 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Aug 1 08:40:07 2017 +0200
----------------------------------------------------------------------
examples/README.adoc | 4 +-
.../README.adoc | 28 +++++
.../pom.xml | 101 +++++++++++++++++++
.../springboot/infinispan/Application.java | 34 +++++++
.../infinispan/CamelInfinispanRoute.java | 56 ++++++++++
.../src/main/resources/application.properties | 20 ++++
examples/pom.xml | 1 +
7 files changed, 243 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b4582687/examples/README.adoc
----------------------------------------------------------------------
diff --git a/examples/README.adoc b/examples/README.adoc
index 29bc0eb..f302ed3 100644
--- a/examples/README.adoc
+++ b/examples/README.adoc
@@ -11,7 +11,7 @@ View the individual example READMEs for details.
### Examples
// examples: START
-Number of Examples: 94 (8 deprecated)
+Number of Examples: 95 (8 deprecated)
[width="100%",cols="4,2,4",options="header"]
|=======================================================================
@@ -68,6 +68,8 @@ Number of Examples: 94 (8 deprecated)
| link:camel-example-hazelcast-kubernetes/ReadMe.md[Hazelcast Kubernetes] (camel-example-hazelcast-kubernetes) | Cloud | An example with Camel and Hazelcast running on Kubernetes
+| link:camel-example-spring-boot-infinispan/README.adoc[Spring Boot Infinispan] (camel-example-spring-boot-infinispan) | Cloud | An example showing the Camel Infinispan component with Spring Boot
+
| link:camel-example-spring-boot-servicecall/README.adoc[Spring Boot Servicecall] (camel-example-spring-boot-servicecall) | Cloud | An example showing how to work with Camel ServiceCall EIP and Spring Boot
| link:camel-example-spring-cloud-servicecall/README.adoc[Spring Cloud Servicecall] (camel-example-spring-cloud-servicecall) | Cloud | An example showing how to work with Camel ServiceCall EIP and Spring Cloud
http://git-wip-us.apache.org/repos/asf/camel/blob/b4582687/examples/camel-example-spring-boot-infinispan/README.adoc
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-infinispan/README.adoc b/examples/camel-example-spring-boot-infinispan/README.adoc
new file mode 100644
index 0000000..a89d9fd
--- /dev/null
+++ b/examples/camel-example-spring-boot-infinispan/README.adoc
@@ -0,0 +1,28 @@
+# Spring Boot Example with Infinispan
+
+### Introduction
+
+This example demonstrates how you can use Camel-Infinispan Starter component. The example is really simple: put a key/value pair in a remote cache and get the same key.
+You'll need a running Infinispan server to run this example.
+
+### Build
+
+You can build this example using:
+
+ $ mvn package
+
+### Run
+
+You can run this example using:
+
+ $ mvn spring-boot:run
+
+And you should see output in the console.
+
+### Help
+
+If you hit any problems please let us know on the http://camel.apache.org/discussion-forums.html[Camel Forums].
+
+Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy!
+
+The Camel riders!
http://git-wip-us.apache.org/repos/asf/camel/blob/b4582687/examples/camel-example-spring-boot-infinispan/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-infinispan/pom.xml b/examples/camel-example-spring-boot-infinispan/pom.xml
new file mode 100644
index 0000000..9afea3c
--- /dev/null
+++ b/examples/camel-example-spring-boot-infinispan/pom.xml
@@ -0,0 +1,101 @@
+<?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.example</groupId>
+ <artifactId>examples</artifactId>
+ <version>2.20.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-spring-boot-infinispan</artifactId>
+ <name>Camel :: Example :: Spring Boot with Infinispan</name>
+ <description>An example showing the Camel Infinispan component with Spring Boot</description>
+
+ <properties>
+ <category>Cloud</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</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <!-- Camel -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-boot-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-infinispan-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</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>
http://git-wip-us.apache.org/repos/asf/camel/blob/b4582687/examples/camel-example-spring-boot-infinispan/src/main/java/org/apache/camel/example/springboot/infinispan/Application.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-infinispan/src/main/java/org/apache/camel/example/springboot/infinispan/Application.java b/examples/camel-example-spring-boot-infinispan/src/main/java/org/apache/camel/example/springboot/infinispan/Application.java
new file mode 100644
index 0000000..c37e1e4
--- /dev/null
+++ b/examples/camel-example-spring-boot-infinispan/src/main/java/org/apache/camel/example/springboot/infinispan/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.infinispan;
+
+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
http://git-wip-us.apache.org/repos/asf/camel/blob/b4582687/examples/camel-example-spring-boot-infinispan/src/main/java/org/apache/camel/example/springboot/infinispan/CamelInfinispanRoute.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-infinispan/src/main/java/org/apache/camel/example/springboot/infinispan/CamelInfinispanRoute.java b/examples/camel-example-spring-boot-infinispan/src/main/java/org/apache/camel/example/springboot/infinispan/CamelInfinispanRoute.java
new file mode 100644
index 0000000..a7f519b
--- /dev/null
+++ b/examples/camel-example-spring-boot-infinispan/src/main/java/org/apache/camel/example/springboot/infinispan/CamelInfinispanRoute.java
@@ -0,0 +1,56 @@
+/**
+ * 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.infinispan;
+
+import java.io.IOException;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.infinispan.InfinispanConstants;
+import org.apache.camel.component.infinispan.InfinispanOperation;
+import org.infinispan.client.hotrod.RemoteCacheManager;
+import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.stereotype.Component;
+
+/**
+ * A simple Camel Infinispan route example using Spring-boot
+ */
+@Component
+public class CamelInfinispanRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("timer://foo?period=10000&repeatCount=1")
+ .setHeader(InfinispanConstants.OPERATION).constant(InfinispanOperation.PUT)
+ .setHeader(InfinispanConstants.KEY).constant("1")
+ .setHeader(InfinispanConstants.VALUE).constant("test")
+ .to("infinispan://default?cacheContainer=#cacheContainer")
+ .setHeader(InfinispanConstants.OPERATION).constant(InfinispanOperation.GET)
+ .setHeader(InfinispanConstants.KEY).constant("1")
+ .to("infinispan://default?cacheContainer=#cacheContainer").log("Received body: ${body}");
+
+ }
+
+ @Bean(name = "cacheContainer")
+ public RemoteCacheManager remoteCacheManager() throws IOException {
+ ConfigurationBuilder builder = new ConfigurationBuilder();
+ builder.addServer().host("localhost")
+ .port(11222);
+ return new RemoteCacheManager(builder.build());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/b4582687/examples/camel-example-spring-boot-infinispan/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-boot-infinispan/src/main/resources/application.properties b/examples/camel-example-spring-boot-infinispan/src/main/resources/application.properties
new file mode 100644
index 0000000..bfa2883
--- /dev/null
+++ b/examples/camel-example-spring-boot-infinispan/src/main/resources/application.properties
@@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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=Infinispan
+camel.springboot.main-run-controller=true
+
http://git-wip-us.apache.org/repos/asf/camel/blob/b4582687/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index ea5c14a..aa99f0e 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -97,6 +97,7 @@
<module>camel-example-spring-boot</module>
<module>camel-example-spring-boot-activemq</module>
<module>camel-example-spring-boot-geocoder</module>
+ <module>camel-example-spring-boot-infinispan</module>
<module>camel-example-spring-boot-live-reload</module>
<module>camel-example-spring-boot-metrics</module>
<module>camel-example-spring-boot-pojo</module>