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/30 08:17:18 UTC
[3/3] camel git commit: CAMEL-11714 - Add a Kubernetes Camel-gRPC
spring-boot example
CAMEL-11714 - Add a Kubernetes Camel-gRPC spring-boot example
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2c5c8b6d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2c5c8b6d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2c5c8b6d
Branch: refs/heads/master
Commit: 2c5c8b6d7ba95e9173572cde7b6e8c3490218d79
Parents: 02b3698
Author: Andrea Cosentino <an...@gmail.com>
Authored: Tue Aug 29 16:03:43 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Aug 30 10:16:28 2017 +0200
----------------------------------------------------------------------
.../camel-example-grpc-kubernetes/README.adoc | 66 ++++++++
.../hello-camel-grpc-client-kubernetes/pom.xml | 162 +++++++++++++++++++
.../example/springboot/grpc/Application.java | 34 ++++
.../example/springboot/grpc/CamelGrpcRoute.java | 45 ++++++
.../src/main/proto/hellocamel.proto | 39 +++++
.../src/main/resources/application.properties | 19 +++
.../hello-camel-grpc-server-kubernetes/pom.xml | 128 +++++++++++++++
.../camel/examples/grpc/HelloCamelServer.java | 82 ++++++++++
.../src/main/proto/hellocamel.proto | 39 +++++
examples/camel-example-grpc-kubernetes/pom.xml | 45 ++++++
10 files changed, 659 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2c5c8b6d/examples/camel-example-grpc-kubernetes/README.adoc
----------------------------------------------------------------------
diff --git a/examples/camel-example-grpc-kubernetes/README.adoc b/examples/camel-example-grpc-kubernetes/README.adoc
new file mode 100644
index 0000000..637d5b4
--- /dev/null
+++ b/examples/camel-example-grpc-kubernetes/README.adoc
@@ -0,0 +1,66 @@
+# Spring Boot Example with gRPC
+
+### Introduction
+
+This example demonstrates how you can use Camel-gRPC Starter component. The example is composed of a standalone gRPC server and a Camel Spring-boot gRPC route acting as client.
+
+### Server
+
+You can build the server under the directory hello-camel-grpc-server with:
+
+ $ mvn clean install
+
+and then run the server with
+
+ $ mvn exec:java
+
+You should see the following output:
+
+[source,bash]
+----
+Aug 08, 2017 8:00:00 AM org.apache.camel.examples.grpc.HelloCamelServer start
+INFO: Server started. I'm listening on 50051
+----
+
+### Run the client
+
+You can build the client example under the directory hello-camel-grpc-client with:
+
+ $ mvn clean install
+
+and then run the example with
+
+ $ mvn spring-boot:run
+
+And you should see this output in the console.
+
+[source,bash]
+----
+2017-08-08 08:01:14.530 INFO 7096 --- [ main] o.a.c.e.springboot.grpc.Application : Starting Application on ghost with PID 7096 (/home/oscerd/workspace/apache-camel/camel/examples/camel-example-spring-boot-grpc/hello-camel-grpc-client/target/classes started by oscerd in /home/oscerd/workspace/apache-camel/camel/examples/camel-example-spring-boot-grpc/hello-camel-grpc-client)
+2017-08-08 08:01:14.532 INFO 7096 --- [ main] o.a.c.e.springboot.grpc.Application : No active profile set, falling back to default profiles: default
+2017-08-08 08:01:14.563 INFO 7096 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@540ff973: startup date [Tue Aug 08 08:01:14 CEST 2017]; root of context hierarchy
+2017-08-08 08:01:15.177 INFO 7096 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.apache.camel.spring.boot.CamelAutoConfiguration' of type [org.apache.camel.spring.boot.CamelAutoConfiguration$$EnhancerBySpringCGLIB$$78492c0f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
+2017-08-08 08:01:15.447 INFO 7096 --- [ main] o.a.c.i.converter.DefaultTypeConverter : Type converters loaded (core: 192, classpath: 1)
+2017-08-08 08:01:15.844 INFO 7096 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
+2017-08-08 08:01:15.894 INFO 7096 --- [ main] o.a.camel.spring.boot.RoutesCollector : Loading additional Camel XML routes from: classpath:camel/*.xml
+2017-08-08 08:01:15.894 INFO 7096 --- [ main] o.a.camel.spring.boot.RoutesCollector : Loading additional Camel XML rests from: classpath:camel-rest/*.xml
+2017-08-08 08:01:15.895 INFO 7096 --- [ main] o.a.camel.spring.boot.RoutesCollector : Starting CamelMainRunController to ensure the main thread keeps running
+2017-08-08 08:01:15.898 INFO 7096 --- [inRunController] o.a.camel.spring.SpringCamelContext : Apache Camel 2.20.0-SNAPSHOT (CamelContext: gRPC) is starting
+2017-08-08 08:01:15.899 INFO 7096 --- [inRunController] o.a.c.m.ManagedManagementStrategy : JMX is enabled
+2017-08-08 08:01:15.904 INFO 7096 --- [ main] o.a.c.e.springboot.grpc.Application : Started Application in 1.897 seconds (JVM running for 7.75)
+2017-08-08 08:01:16.074 INFO 7096 --- [inRunController] o.a.camel.spring.SpringCamelContext : StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
+2017-08-08 08:01:16.118 INFO 7096 --- [inRunController] o.a.camel.component.grpc.GrpcProducer : Creating channel to the remote gRPC server localhost:50051
+2017-08-08 08:01:16.214 INFO 7096 --- [inRunController] o.a.camel.spring.SpringCamelContext : Route: route1 started and consuming from: timer://foo?period=10000&repeatCount=1
+2017-08-08 08:01:16.216 INFO 7096 --- [inRunController] o.a.camel.spring.SpringCamelContext : Total 1 routes, of which 1 are started.
+2017-08-08 08:01:16.216 INFO 7096 --- [inRunController] o.a.camel.spring.SpringCamelContext : Apache Camel 2.20.0-SNAPSHOT (CamelContext: gRPC) started in 0.319 seconds
+2017-08-08 08:01:17.534 INFO 7096 --- [2 - timer://foo] route1 : Received message: "Hello Camel"
+
+----
+
+### 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/2c5c8b6d/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/pom.xml b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/pom.xml
new file mode 100644
index 0000000..c67edd6
--- /dev/null
+++ b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/pom.xml
@@ -0,0 +1,162 @@
+<?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>camel-example-grpc-kubernetes</artifactId>
+ <version>2.20.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-hello-grpc-client-kubernetes</artifactId>
+ <name>Camel :: Example :: gRPC :: Hello Camel Client Kubernetes</name>
+ <description>An example showing the Camel Grpc component with Spring Boot runnning on Kubernetes</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-grpc-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>
+ <extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.5.0.Final</version>
+ </extension>
+ </extensions>
+ <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>
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ <version>${protobuf-maven-plugin-version}</version>
+ <configuration>
+ <protocArtifact>com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier}</protocArtifact>
+ <pluginId>grpc-java</pluginId>
+ <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc-version}:exe:${os.detected.classifier}</pluginArtifact>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>compile-custom</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>kubernetes-install</id>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>fabric8-maven-plugin</artifactId>
+ <version>3.2.31</version>
+ <configuration>
+ <generator>
+ <config>
+ <java-exec>
+ <mainClass>org.apache.camel.example.springboot.grpc.Application</mainClass>
+ </java-exec>
+ </config>
+ </generator>
+ <enricher>
+ <config>
+ <fmp-service>
+ <name>grpc-client</name>
+ </fmp-service>
+ </config>
+ </enricher>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>resource</goal>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/2c5c8b6d/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/java/org/apache/camel/example/springboot/grpc/Application.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/java/org/apache/camel/example/springboot/grpc/Application.java b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/java/org/apache/camel/example/springboot/grpc/Application.java
new file mode 100644
index 0000000..5300c92
--- /dev/null
+++ b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/java/org/apache/camel/example/springboot/grpc/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.grpc;
+
+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/2c5c8b6d/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/java/org/apache/camel/example/springboot/grpc/CamelGrpcRoute.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/java/org/apache/camel/example/springboot/grpc/CamelGrpcRoute.java b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/java/org/apache/camel/example/springboot/grpc/CamelGrpcRoute.java
new file mode 100644
index 0000000..95d40f6
--- /dev/null
+++ b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/java/org/apache/camel/example/springboot/grpc/CamelGrpcRoute.java
@@ -0,0 +1,45 @@
+/**
+ * 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.grpc;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.examples.CamelHelloRequest;
+import org.springframework.stereotype.Component;
+
+/**
+ * A simple Camel Grpc route example using Spring-boot
+ */
+@Component
+public class CamelGrpcRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+
+ CamelHelloRequest request = CamelHelloRequest.newBuilder().setName("Camel").build();
+ from("timer://foo?period=10000&repeatCount=1").process(new Processor() {
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setBody(request, CamelHelloRequest.class);
+
+ }
+ }).to("grpc://grpc-server:80/org.apache.camel.examples.CamelHello?method=sayHelloToCamel&synchronous=true").log("Received ${body}");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2c5c8b6d/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/proto/hellocamel.proto
----------------------------------------------------------------------
diff --git a/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/proto/hellocamel.proto b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/proto/hellocamel.proto
new file mode 100644
index 0000000..787ae12
--- /dev/null
+++ b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/proto/hellocamel.proto
@@ -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.
+ */
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.camel.examples";
+option java_outer_classname = "HelloCamelProto";
+
+package org.apache.camel.examples;
+
+// The camel hello service definition.
+service CamelHello {
+ // Sends a greeting
+ rpc SayHelloToCamel (CamelHelloRequest) returns (CamelHelloReply) {}
+}
+
+// The request message containing the user's name.
+message CamelHelloRequest {
+ string name = 1;
+}
+
+// The response message containing the greetings
+message CamelHelloReply {
+ string message = 1;
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2c5c8b6d/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/resources/application.properties b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/resources/application.properties
new file mode 100644
index 0000000..fbf3831
--- /dev/null
+++ b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-client-kubernetes/src/main/resources/application.properties
@@ -0,0 +1,19 @@
+## ---------------------------------------------------------------------------
+## 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=gRPC
+camel.springboot.main-run-controller=true
http://git-wip-us.apache.org/repos/asf/camel/blob/2c5c8b6d/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/pom.xml b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/pom.xml
new file mode 100644
index 0000000..4616874
--- /dev/null
+++ b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/pom.xml
@@ -0,0 +1,128 @@
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.example</groupId>
+ <artifactId>camel-example-grpc-kubernetes</artifactId>
+ <version>2.20.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-hello-grpc-server-kubernetes</artifactId>
+ <name>Camel :: Example :: gRPC :: Hello Camel Server Kubernetes</name>
+ <description>An example showing a simple gRPC server running on Kubernetes</description>
+
+ <properties>
+ <main.class>org.apache.camel.examples.grpc.HelloCamelServer</main.class>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-netty</artifactId>
+ <version>${grpc-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-protobuf</artifactId>
+ <version>${grpc-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-stub</artifactId>
+ <version>${grpc-version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.5.0.Final</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ <version>${protobuf-maven-plugin-version}</version>
+ <configuration>
+ <protocArtifact>com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier}</protocArtifact>
+ <pluginId>grpc-java</pluginId>
+ <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc-version}:exe:${os.detected.classifier}</pluginArtifact>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>compile-custom</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.4.1</version>
+ <executions>
+ <execution>
+ <id>enforce</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireUpperBoundDeps />
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>${exec-maven-plugin-version}</version>
+ <configuration>
+ <mainClass>org.apache.camel.examples.grpc.HelloCamelServer</mainClass>
+ <includePluginDependencies>false</includePluginDependencies>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>kubernetes-install</id>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <plugins>
+
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>fabric8-maven-plugin</artifactId>
+ <version>3.2.31</version>
+ <configuration>
+ <enricher>
+ <config>
+ <fmp-service>
+ <name>grpc-server</name>
+ </fmp-service>
+ </config>
+ </enricher>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>resource</goal>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/2c5c8b6d/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/src/main/java/org/apache/camel/examples/grpc/HelloCamelServer.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/src/main/java/org/apache/camel/examples/grpc/HelloCamelServer.java b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/src/main/java/org/apache/camel/examples/grpc/HelloCamelServer.java
new file mode 100644
index 0000000..9fa0c1a
--- /dev/null
+++ b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/src/main/java/org/apache/camel/examples/grpc/HelloCamelServer.java
@@ -0,0 +1,82 @@
+/**
+ * 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.examples.grpc;
+
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import io.grpc.Server;
+import io.grpc.ServerBuilder;
+import io.grpc.stub.StreamObserver;
+
+import org.apache.camel.examples.CamelHelloGrpc;
+import org.apache.camel.examples.CamelHelloReply;
+import org.apache.camel.examples.CamelHelloRequest;
+
+/**
+ * Server that manages startup/shutdown of a server.
+ */
+public class HelloCamelServer {
+ private static final Logger LOG = Logger.getLogger(HelloCamelServer.class.getName());
+
+ private Server server;
+
+ private void start() throws IOException {
+ /* The port on which the server should run */
+ int port = 8080;
+ server = ServerBuilder.forPort(port).addService(new HelloCamelImpl()).build().start();
+ LOG.info("Server started. I'm listening on " + port);
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ HelloCamelServer.this.stop();
+ }
+ });
+ }
+
+ private void stop() {
+ if (server != null) {
+ server.shutdown();
+ }
+ }
+
+ private void blockUntilShutdown() throws InterruptedException {
+ if (server != null) {
+ server.awaitTermination();
+ }
+ }
+
+ /**
+ * Main needed to launch server from command line
+ */
+ public static void main(String[] args) throws IOException, InterruptedException {
+ final HelloCamelServer server = new HelloCamelServer();
+ server.start();
+ server.blockUntilShutdown();
+ }
+
+ static class HelloCamelImpl extends CamelHelloGrpc.CamelHelloImplBase {
+
+ @Override
+ public void sayHelloToCamel(CamelHelloRequest req, StreamObserver<CamelHelloReply> responseObserver) {
+ CamelHelloReply reply = CamelHelloReply.newBuilder().setMessage("Hello " + req.getName()).build();
+ responseObserver.onNext(reply);
+ responseObserver.onCompleted();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2c5c8b6d/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/src/main/proto/hellocamel.proto
----------------------------------------------------------------------
diff --git a/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/src/main/proto/hellocamel.proto b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/src/main/proto/hellocamel.proto
new file mode 100644
index 0000000..787ae12
--- /dev/null
+++ b/examples/camel-example-grpc-kubernetes/hello-camel-grpc-server-kubernetes/src/main/proto/hellocamel.proto
@@ -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.
+ */
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.camel.examples";
+option java_outer_classname = "HelloCamelProto";
+
+package org.apache.camel.examples;
+
+// The camel hello service definition.
+service CamelHello {
+ // Sends a greeting
+ rpc SayHelloToCamel (CamelHelloRequest) returns (CamelHelloReply) {}
+}
+
+// The request message containing the user's name.
+message CamelHelloRequest {
+ string name = 1;
+}
+
+// The response message containing the greetings
+message CamelHelloReply {
+ string message = 1;
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/2c5c8b6d/examples/camel-example-grpc-kubernetes/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-grpc-kubernetes/pom.xml b/examples/camel-example-grpc-kubernetes/pom.xml
new file mode 100644
index 0000000..c54fc35
--- /dev/null
+++ b/examples/camel-example-grpc-kubernetes/pom.xml
@@ -0,0 +1,45 @@
+<?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/maven-v4_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-grpc-kubernetes</artifactId>
+ <packaging>pom</packaging>
+ <name>Camel :: Example :: gRPC :: Kubernetes</name>
+ <description>An example showing the Camel gRPC component with Spring Boot running on Kubernetes</description>
+
+ <properties>
+ <category>Cloud</category>
+ </properties>
+
+ <modules>
+ <module>hello-camel-grpc-server-kubernetes</module>
+ <module>hello-camel-grpc-client-kubernetes</module>
+ </modules>
+
+</project>