Skip to content

Commit

Permalink
CAMEL-11711: Camel-example-spring-cloud-servicecall doesn't work out …
Browse files Browse the repository at this point in the history
…of the box
  • Loading branch information
lburgazzoli committed Sep 20, 2017
1 parent 430af9a commit a6e721b
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 90 deletions.
12 changes: 0 additions & 12 deletions examples/camel-example-spring-cloud-servicecall/consumer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,6 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ public void configure() throws Exception {

from("direct:service-call")
.setBody().constant(null)
.removeHeaders("CamelHttp*")
.to("log:service-call?level=INFO&showAll=true&multiline=true")
.choice()
.when(header("serviceId").isEqualTo("service1"))
.serviceCall("service-1")
.convertBodyTo(String.class)
.log("service-1 : ${body}")
.when(header("serviceId").isEqualTo("service2"))
.serviceCall("service-2");
.serviceCall("service-2")
.convertBodyTo(String.class)
.log("service-1 : ${body}");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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
spring.cloud.consul.discovery.register = false

# Camel
camel.springboot.main-run-controller=true
Expand Down
44 changes: 16 additions & 28 deletions examples/camel-example-spring-cloud-servicecall/service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,35 +80,23 @@
<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>
<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>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

CONSUL_VER="0.8.1"
CONSUL_VER="0.9.3"
CONSUL_ZIP="consul_${CONSUL_VER}_linux_amd64.zip"

# cleanup
Expand All @@ -13,32 +13,12 @@ mkdir -p target/consul-data
mkdir -p target/consul-config

if [ ! -f target/${CONSUL_ZIP} ]; then
echo Downloading: https://releases.hashicorp.com/consul/${CONSUL_VER}/${CONSUL_ZIP}
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}
chmod +x target/consul

target/consul \
agent \
Expand All @@ -49,5 +29,5 @@ target/consul \
-bind 0.0.0.0 \
-log-level trace \
-data-dir target/consul-data \
-config-dir target/consul-config \
-config-dir src/main/resources/consul \
-ui
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

CONSUL_VER="0.8.1"
CONSUL_VER="0.9.3"
CONSUL_ZIP="consul_${CONSUL_VER}_darwin_amd64.zip"

# cleanup
Expand All @@ -12,34 +12,11 @@ mkdir -p target/
mkdir -p target/consul-data
mkdir -p target/consul-config


if [ ! -f target/$CONSUL_ZIP ]; then
echo Downloading: https://releases.hashicorp.com/consul/$CONSUL_VER/$CONSUL_ZIP
curl -o target/$CONSUL_ZIP "https://releases.hashicorp.com/consul/$CONSUL_VER/$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
chmod +x target/consul

Expand All @@ -52,5 +29,5 @@ target/consul \
-bind 0.0.0.0 \
-log-level trace \
-data-dir target/consul-data \
-config-dir target/consul-config \
-config-dir src/main/resources/consul \
-ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"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
}]
}

0 comments on commit a6e721b

Please sign in to comment.