You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/03/23 14:27:46 UTC
camel git commit: CAMEL-10877: service-call eip : add a spring-cloud
example
Repository: camel
Updated Branches:
refs/heads/master 7ba190216 -> 64c57a8db
CAMEL-10877: service-call eip : add a spring-cloud example
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/64c57a8d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/64c57a8d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/64c57a8d
Branch: refs/heads/master
Commit: 64c57a8db2ab4760dc580f64b5ec2f4462a81f63
Parents: 7ba1902
Author: lburgazzoli <lb...@gmail.com>
Authored: Thu Mar 23 15:27:06 2017 +0100
Committer: lburgazzoli <lb...@gmail.com>
Committed: Thu Mar 23 15:27:06 2017 +0100
----------------------------------------------------------------------
components/camel-spring-cloud-netflix/pom.xml | 4 -
...ngCloudDiscoveryClientAutoConfiguration.java | 62 ++++++++
...pringCloudLoadBalancerAutoConfiguration.java | 8 +-
examples/README.adoc | 8 +-
.../README.adoc | 53 +++++++
.../consumer/pom.xml | 153 +++++++++++++++++++
.../camel/example/ConsumerApplication.java | 59 +++++++
.../src/main/resources/application.properties | 16 ++
.../consumer/src/main/resources/logback.xml | 34 +++++
.../pom.xml | 40 +++++
.../service/pom.xml | 112 ++++++++++++++
.../service/src/main/bash/consul-run.sh | 52 +++++++
.../camel/example/ServiceApplication.java | 69 +++++++++
.../src/main/resources/application.properties | 8 +
.../service/src/main/resources/logback.xml | 34 +++++
examples/pom.xml | 1 +
16 files changed, 702 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/components/camel-spring-cloud-netflix/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud-netflix/pom.xml b/components/camel-spring-cloud-netflix/pom.xml
index a111462..5d6ca11 100644
--- a/components/camel-spring-cloud-netflix/pom.xml
+++ b/components/camel-spring-cloud-netflix/pom.xml
@@ -63,10 +63,6 @@
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.camel</groupId>
- <artifactId>camel-spring-cloud</artifactId>
- </dependency>
<!-- Testing dependencies -->
<dependency>
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudDiscoveryClientAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudDiscoveryClientAutoConfiguration.java b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudDiscoveryClientAutoConfiguration.java
new file mode 100644
index 0000000..cc29cc4
--- /dev/null
+++ b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudDiscoveryClientAutoConfiguration.java
@@ -0,0 +1,62 @@
+/**
+ * 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.spring.cloud;
+
+
+import org.apache.camel.cloud.LoadBalancer;
+import org.apache.camel.spring.boot.cloud.CamelCloudAutoConfiguration;
+import org.apache.camel.spring.boot.cloud.CamelCloudConfigurationProperties;
+import org.apache.camel.spring.boot.cloud.CamelCloudServiceDiscovery;
+import org.apache.camel.spring.boot.cloud.CamelCloudServiceDiscoveryAutoConfiguration;
+import org.apache.camel.spring.boot.util.GroupCondition;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
+import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration;
+import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@ConditionalOnBean({ CamelCloudAutoConfiguration.class, LoadBalancerClient.class })
+@AutoConfigureAfter({ LoadBalancerAutoConfiguration.class, CamelCloudServiceDiscoveryAutoConfiguration.class })
+@EnableConfigurationProperties(CamelCloudConfigurationProperties.class)
+@Conditional(CamelSpringCloudDiscoveryClientAutoConfiguration.LoadBalancerCondition.class)
+public class CamelSpringCloudDiscoveryClientAutoConfiguration {
+
+ @Bean(name = "load-balancer-discovery-client")
+ @ConditionalOnMissingBean
+ public DiscoveryClient serviceDiscoveryClient(CamelCloudServiceDiscovery serviceDiscovery) {
+ return new CamelSpringCloudDiscoveryClient("service-discovery-client", serviceDiscovery);
+ }
+
+ // *******************************
+ // Condition
+ // *******************************
+
+ public static class LoadBalancerCondition extends GroupCondition {
+ public LoadBalancerCondition() {
+ super(
+ "camel.cloud",
+ "camel.cloud.discovery-client"
+ );
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancerAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancerAutoConfiguration.java b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancerAutoConfiguration.java
index 8ac2119..c6bcf74 100644
--- a/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancerAutoConfiguration.java
+++ b/components/camel-spring-cloud/src/main/java/org/apache/camel/spring/cloud/CamelSpringCloudLoadBalancerAutoConfiguration.java
@@ -25,6 +25,7 @@ import org.apache.camel.spring.boot.cloud.CamelCloudServiceDiscoveryAutoConfigur
import org.apache.camel.spring.boot.util.GroupCondition;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration;
@@ -39,16 +40,13 @@ import org.springframework.context.annotation.Configuration;
@EnableConfigurationProperties(CamelCloudConfigurationProperties.class)
@Conditional(CamelSpringCloudLoadBalancerAutoConfiguration.LoadBalancerCondition.class)
public class CamelSpringCloudLoadBalancerAutoConfiguration {
+
@Bean(name = "load-balancer")
+ @ConditionalOnMissingBean
public LoadBalancer cloudLoadBalancer(LoadBalancerClient loadBalancerClient) {
return new CamelSpringCloudLoadBalancer(loadBalancerClient);
}
- @Bean(name = "load-balancer-discovery-client")
- public DiscoveryClient serviceDiscoveryClient(CamelCloudServiceDiscovery serviceDiscovery) {
- return new CamelSpringCloudDiscoveryClient("service-discovery-client", serviceDiscovery);
- }
-
// *******************************
// Condition
// *******************************
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/examples/README.adoc
----------------------------------------------------------------------
diff --git a/examples/README.adoc b/examples/README.adoc
index 06e4da6..4f1825c 100644
--- a/examples/README.adoc
+++ b/examples/README.adoc
@@ -11,12 +11,16 @@ View the individual example READMEs for details.
### Examples
// examples: START
-Number of Examples: 90 (9 deprecated)
+Number of Examples: 92 (10 deprecated)
[width="100%",cols="4,2,4",options="header"]
|=======================================================================
| Example | Category | Description
+| link:camel-example-spring-boot-servicecall/README.adoc[Spring Boot Servicecall] (camel-example-spring-boot-servicecall) | | 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) | | An example showing how to work with Camel ServiceCall EIP and Spring Cloud
+
| link:camel-example-cdi/README.md[CDI] (camel-example-cdi) | Beginner | An example showing how to work with Camel and CDI for dependency injection
| link:camel-example-cdi-properties/README.md[CDI Properties] (camel-example-cdi-properties) | Beginner | DeltaSpike configuration properties CDI example
@@ -131,7 +135,7 @@ Number of Examples: 90 (9 deprecated)
| link:camel-example-box-osgi/README.md[Box OSGi] (camel-example-box-osgi) | OSGi | An example which use a Box Endpoint in OSGi
-| link:camel-example-cdi-osgi/README.md[CDI OSGi] (camel-example-cdi-osgi) | OSGi | PAX CDI example
+| link:camel-example-cdi-osgi/README.md[CDI OSGi] (camel-example-cdi-osgi) | OSGi | *deprecated* PAX CDI example
| link:camel-example-cxf-blueprint/README.md[CXF Blueprint] (camel-example-cxf-blueprint) | OSGi | An example which use a CXF consumer and the OSGI HTTP Service
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/examples/camel-example-spring-cloud-servicecall/README.adoc
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-cloud-servicecall/README.adoc b/examples/camel-example-spring-cloud-servicecall/README.adoc
new file mode 100644
index 0000000..8d5f385
--- /dev/null
+++ b/examples/camel-example-spring-cloud-servicecall/README.adoc
@@ -0,0 +1,53 @@
+# Spring Cloud and ServiceCall EIP Example
+
+This example show how to use Camel with ServiceCall EIP with spring-cloud and consul.
+
+This example includes two maven modules:
+
+ - service that exposes a number of services
+ - consumer that consumes services
+
+## Configuration
+
+The consumer is configured in the src/main/resources/application.properties
+
+## Build
+
+You can build this example using
+
+ mvn compile
+
+## Run the example
+
+Using multiple shells:
+
+ - start consul:
+
+ $ cd services
+ $ src/main/bash/consul-run.sh
+
+ - start the service:
+
+ $ cd service
+ $ mvn spring-boot:run
+
+ - start the consumer
+
+ $ cd consumer
+ $ mvn spring-boot:run
+
+## Test the example:
+
+In a new shell:
+
+ $ curl localhost:8080/camel/serviceCall/service1
+ Hi!, I'm service-1 on camel-1/route1
+ $ curl localhost:8080/camel/serviceCall/service2
+ Hi!, I'm service-1 on camel-1/route2
+
+If you keep calling the http endpoint you'll notice they are consumed using a round robin policy and that only the services matching specific tags are consumed.
+
+## More information
+
+You can find more information about Apache Camel at the website: http://camel.apache.org/
+
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/examples/camel-example-spring-cloud-servicecall/consumer/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-cloud-servicecall/consumer/pom.xml b/examples/camel-example-spring-cloud-servicecall/consumer/pom.xml
new file mode 100644
index 0000000..a2fee1f
--- /dev/null
+++ b/examples/camel-example-spring-cloud-servicecall/consumer/pom.xml
@@ -0,0 +1,153 @@
+<?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</groupId>
+ <artifactId>camel-example-spring-cloud-servicecall</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-spring-cloud-servicecall-consumer</artifactId>
+ <name>Camel :: Example :: Spring Cloud :: ServiceCall :: Consumer</name>
+ <description>An example showing how to work with Camel ServiceCall EIP and Spring Cloud (Consumer)</description>
+
+ <properties>
+ <category>Beginner</category>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <spring.boot-version>${spring-boot-version}</spring.boot-version>
+ <spring.cloud-version>1.1.3.RELEASE</spring.cloud-version>
+ </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>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-consul-dependencies</artifactId>
+ <version>${spring.cloud-version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <!-- Camel BOM -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-boot-dependencies</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <!-- Spring Boot -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-undertow</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-actuator</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-starter-consul-discovery</artifactId>
+ </dependency>
+
+ <!-- Camel -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-boot-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-cloud-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-servlet-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-undertow-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-http-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jackson-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</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/64c57a8d/examples/camel-example-spring-cloud-servicecall/consumer/src/main/java/org/apache/camel/example/ConsumerApplication.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-cloud-servicecall/consumer/src/main/java/org/apache/camel/example/ConsumerApplication.java b/examples/camel-example-spring-cloud-servicecall/consumer/src/main/java/org/apache/camel/example/ConsumerApplication.java
new file mode 100644
index 0000000..6b27931
--- /dev/null
+++ b/examples/camel-example-spring-cloud-servicecall/consumer/src/main/java/org/apache/camel/example/ConsumerApplication.java
@@ -0,0 +1,59 @@
+/**
+ * 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;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.stereotype.Component;
+
+//CHECKSTYLE:OFF
+/**
+ * A sample Spring Boot application that starts the Camel routes.
+ */
+@SpringBootApplication
+@EnableDiscoveryClient
+public class ConsumerApplication {
+ @Component
+ public class ConsumerRoute extends RouteBuilder {
+ @Override
+ public void configure() throws Exception {
+ rest("/serviceCall")
+ .get("/{serviceId}")
+ .to("direct:service-call");
+
+ from("direct:service-call")
+ .setBody().constant(null)
+ .to("log:service-call?level=INFO&showAll=true&multiline=true")
+ .choice()
+ .when(header("serviceId").isEqualTo("service1"))
+ .serviceCall("service-1", "undertow:http://service-1")
+ .when(header("serviceId").isEqualTo("service2"))
+ .serviceCall("service-2", "undertow:http://service-2");
+ }
+ }
+
+ /**
+ * A main method to start this application.
+ */
+ public static void main(String[] args) {
+ SpringApplication.run(ConsumerApplication.class, args);
+ }
+
+}
+//CHECKSTYLE:ON
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/examples/camel-example-spring-cloud-servicecall/consumer/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-cloud-servicecall/consumer/src/main/resources/application.properties b/examples/camel-example-spring-cloud-servicecall/consumer/src/main/resources/application.properties
new file mode 100644
index 0000000..970cbd7
--- /dev/null
+++ b/examples/camel-example-spring-cloud-servicecall/consumer/src/main/resources/application.properties
@@ -0,0 +1,16 @@
+# Spring Boot
+endpoints.enabled=false
+endpoints.health.enabled=true
+
+# Spring cloud
+spring.cloud.consul.config.enabled=false
+spring.cloud.consul.discovery.enabled=true
+spring.cloud.consul.discovery.server-list-query-tags[service-1] = camel
+spring.cloud.consul.discovery.server-list-query-tags[service-2] = service-call
+
+# Camel
+camel.springboot.main-run-controller=true
+camel.springboot.jmx-enabled=false
+
+camel.rest.component=servlet
+camel.rest.binding-mode=auto
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/examples/camel-example-spring-cloud-servicecall/consumer/src/main/resources/logback.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-cloud-servicecall/consumer/src/main/resources/logback.xml b/examples/camel-example-spring-cloud-servicecall/consumer/src/main/resources/logback.xml
new file mode 100644
index 0000000..e2bb6f1
--- /dev/null
+++ b/examples/camel-example-spring-cloud-servicecall/consumer/src/main/resources/logback.xml
@@ -0,0 +1,34 @@
+<?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.
+-->
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n</pattern>
+ </encoder>
+ <file>target/camel-example-spring-boot-servicecall-consumer.log</file>
+ </appender>
+ <root level="INFO">
+ <!--<appender-ref ref="FILE"/>-->
+ <appender-ref ref="STDOUT"/>
+ </root>
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/examples/camel-example-spring-cloud-servicecall/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-cloud-servicecall/pom.xml b/examples/camel-example-spring-cloud-servicecall/pom.xml
new file mode 100644
index 0000000..10c3517
--- /dev/null
+++ b/examples/camel-example-spring-cloud-servicecall/pom.xml
@@ -0,0 +1,40 @@
+<?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</groupId>
+ <artifactId>examples</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-spring-cloud-servicecall</artifactId>
+ <name>Camel :: Example :: Spring Cloud :: ServiceCall</name>
+ <description>An example showing how to work with Camel ServiceCall EIP and Spring Cloud</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>consumer</module>
+ <module>service</module>
+ </modules>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/examples/camel-example-spring-cloud-servicecall/service/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-cloud-servicecall/service/pom.xml b/examples/camel-example-spring-cloud-servicecall/service/pom.xml
new file mode 100644
index 0000000..ef8e7eb
--- /dev/null
+++ b/examples/camel-example-spring-cloud-servicecall/service/pom.xml
@@ -0,0 +1,112 @@
+<?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</groupId>
+ <artifactId>camel-example-spring-cloud-servicecall</artifactId>
+ <version>2.19.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-example-spring-cloud-servicecall-service</artifactId>
+ <name>Camel :: Example :: Spring Cloud :: ServiceCall :: Service</name>
+ <description>An example showing how to work with Camel ServiceCall EIP and Spring Cloud (Service)</description>
+
+ <properties>
+ <category>Beginner</category>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <spring.boot-version>${spring-boot-version}</spring.boot-version>
+ </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</groupId>
+ <artifactId>camel-spring-boot-dependencies</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <!-- Spring Boot -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <!-- Camel -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-spring-boot-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-undertow-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</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/64c57a8d/examples/camel-example-spring-cloud-servicecall/service/src/main/bash/consul-run.sh
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-cloud-servicecall/service/src/main/bash/consul-run.sh b/examples/camel-example-spring-cloud-servicecall/service/src/main/bash/consul-run.sh
new file mode 100755
index 0000000..f5ac79c
--- /dev/null
+++ b/examples/camel-example-spring-cloud-servicecall/service/src/main/bash/consul-run.sh
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+
+CONSUL_VER="0.7.5"
+CONSUL_ZIP="consul_${CONSUL_VER}_linux_amd64.zip"
+
+# cleanup
+rm -rf "target/consul-data"
+rm -rf "target/consul-config"
+rm -rf "target/consul"
+
+mkdir -p target/
+mkdir -p target/consul-data
+mkdir -p target/consul-config
+
+if [ ! -f target/${CONSUL_ZIP} ]; then
+ wget "https://releases.hashicorp.com/consul/${CONSUL_VER}/${CONSUL_ZIP}" -O target/${CONSUL_ZIP}
+fi
+
+cat > target/consul-config/services.json <<EOF
+{
+ "services": [{
+ "id": "s1i1", "name": "service-1", "tags": ["camel", "service-call"], "address": "localhost", "port": 9011
+ }, {
+ "id": "s1i2", "name": "service-1", "tags": ["camel", "service-call"], "address": "localhost", "port": 9012
+ }, {
+ "id": "s1i3", "name": "service-1", "tags": ["camel", "service-call"], "address": "localhost", "port": 9013
+ }, {
+ "id": "s1i4", "name": "service-1", "address": "localhost", "port": 9014
+ }, {
+ "id": "s2i1", "name": "service-2", "tags": ["camel", "service-call"], "address": "localhost", "port": 9021
+ }, {
+ "id": "s2i2", "name": "service-2", "tags": ["camel", "service-call"], "address": "localhost", "port": 9022
+ }, {
+ "id": "s2i3", "name": "service-2", "tags": ["camel", "service-call"], "address": "localhost", "port": 9023
+ }, {
+ "id": "s2i4", "name": "service-2", "address": "localhost", "port": 9024
+ }]
+}
+EOF
+
+unzip -d target target/${CONSUL_ZIP}
+
+target/consul \
+ agent \
+ -server \
+ -bootstrap \
+ -datacenter camel \
+ -advertise 127.0.0.1 \
+ -bind 0.0.0.0 \
+ -log-level trace \
+ -data-dir target/consul-data \
+ -config-dir target/consul-config
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/examples/camel-example-spring-cloud-servicecall/service/src/main/java/org/apache/camel/example/ServiceApplication.java
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-cloud-servicecall/service/src/main/java/org/apache/camel/example/ServiceApplication.java b/examples/camel-example-spring-cloud-servicecall/service/src/main/java/org/apache/camel/example/ServiceApplication.java
new file mode 100644
index 0000000..e6454d6
--- /dev/null
+++ b/examples/camel-example-spring-cloud-servicecall/service/src/main/java/org/apache/camel/example/ServiceApplication.java
@@ -0,0 +1,69 @@
+/**
+ * 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;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.stereotype.Component;
+
+//CHECKSTYLE:OFF
+/**
+ * A sample Spring Boot application that starts the Camel routes.
+ */
+@SpringBootApplication
+public class ServiceApplication {
+
+ @Component
+ public class Service1Route extends RouteBuilder {
+ public void configure() throws Exception {
+ from("undertow:http://localhost:9011")
+ .to("log:org.apache.camel.example?level=INFO&showAll=true&multiline=true")
+ .transform().simple("Hi!, I'm service-1 on ${camelId}/${routeId}");
+ from("undertow:http://localhost:9012")
+ .to("log:org.apache.camel.example?level=INFO&showAll=true&multiline=true")
+ .transform().simple("Hi!, I'm service-1 on ${camelId}/${routeId}");
+ from("undertow:http://localhost:9013")
+ .to("log:org.apache.camel.example?level=INFO&showAll=true&multiline=true")
+ .transform().simple("Hi!, I'm service-1 on ${camelId}/${routeId}");
+ }
+ }
+
+ @Component
+ public class Service2Route extends RouteBuilder {
+ public void configure() throws Exception {
+ from("undertow:http://localhost:9021")
+ .to("log:org.apache.camel.example?level=INFO&showAll=true&multiline=true")
+ .transform().simple("Hi!, I'm service-2 on ${camelId}/${routeId}");
+ from("undertow:http://localhost:9022")
+ .to("log:org.apache.camel.example?level=INFO&showAll=true&multiline=true")
+ .transform().simple("Hi!, I'm service-2 on ${camelId}/${routeId}");
+ from("undertow:http://localhost:9023")
+ .to("log:org.apache.camel.example?level=INFO&showAll=true&multiline=true")
+ .transform().simple("Hi!, I'm service-2 on ${camelId}/${routeId}");
+ }
+ }
+
+ /**
+ * A main method to start this application.
+ */
+ public static void main(String[] args) {
+ SpringApplication.run(ServiceApplication.class, args);
+ }
+
+}
+//CHECKSTYLE:ON
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/examples/camel-example-spring-cloud-servicecall/service/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-cloud-servicecall/service/src/main/resources/application.properties b/examples/camel-example-spring-cloud-servicecall/service/src/main/resources/application.properties
new file mode 100644
index 0000000..3585779
--- /dev/null
+++ b/examples/camel-example-spring-cloud-servicecall/service/src/main/resources/application.properties
@@ -0,0 +1,8 @@
+# Spring Boot
+endpoints.enabled=false
+endpoints.health.enabled=true
+
+# Camel
+camel.springboot.main-run-controller=true
+camel.springboot.jmx-enabled=false
+
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/examples/camel-example-spring-cloud-servicecall/service/src/main/resources/logback.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-cloud-servicecall/service/src/main/resources/logback.xml b/examples/camel-example-spring-cloud-servicecall/service/src/main/resources/logback.xml
new file mode 100644
index 0000000..39249ae
--- /dev/null
+++ b/examples/camel-example-spring-cloud-servicecall/service/src/main/resources/logback.xml
@@ -0,0 +1,34 @@
+<?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.
+-->
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n</pattern>
+ </encoder>
+ </appender>
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n</pattern>
+ </encoder>
+ <file>target/camel-example-spring-boot-servicecall-service-1.log</file>
+ </appender>
+ <root level="INFO">
+ <!--<appender-ref ref="FILE"/>-->
+ <appender-ref ref="STDOUT"/>
+ </root>
+</configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/64c57a8d/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 352d04e..bb82380 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -94,6 +94,7 @@
<module>camel-example-spring-boot-rest-jpa</module>
<module>camel-example-spring-boot-rest-swagger</module>
<module>camel-example-spring-boot-servicecall</module>
+ <module>camel-example-spring-cloud-servicecall</module>
<module>camel-example-spring-dm</module>
<module>camel-example-spring-javaconfig</module>
<module>camel-example-spring-jms</module>