Skip to content

Commit acb019b

Browse files
committed
Add missing code and add a script to check that everything compile
1 parent 541ea1e commit acb019b

File tree

20 files changed

+795
-14
lines changed

20 files changed

+795
-14
lines changed

Diff for: .editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
trim_trailing_whitespace = true
8+
end_of_line = lf
9+
insert_final_newline = true

Diff for: .scripts/package-all.sh

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/usr/bin/env bash
2+
3+
4+
function check {
5+
if [ $? -eq 0 ]; then
6+
echo "Build success - OK"
7+
else
8+
echo "Build success - KO !!!!"
9+
exit 1
10+
fi
11+
}
12+
13+
echo "Checking hello-vertx"
14+
cd hello-vertx
15+
mvn clean package > build.txt
16+
check
17+
cd ..
18+
19+
# Microservices
20+
21+
cd microservices
22+
23+
echo "Checking HTTP"
24+
cd hello-microservice-http
25+
mvn clean package > build.txt
26+
check
27+
cd ..
28+
29+
echo "Checking HTTP Consumer"
30+
cd hello-consumer-microservice-http
31+
mvn clean package > build.txt
32+
check
33+
cd ..
34+
35+
echo "Checking Message"
36+
cd hello-microservice-message
37+
mvn clean package > build.txt
38+
check
39+
cd ..
40+
41+
echo "Checking Message Consumer"
42+
cd hello-consumer-microservice-message
43+
mvn clean package > build.txt
44+
check
45+
cd ..
46+
47+
echo "Checking Message Faulty"
48+
cd hello-microservice-faulty
49+
mvn clean package > build.txt
50+
check
51+
cd ..
52+
53+
echo "Checking Message Consumer Timeout"
54+
cd hello-consumer-microservice-timeout
55+
mvn clean package > build.txt
56+
check
57+
cd ..
58+
59+
cd ..
60+
61+
# Openshift
62+
cd openshift
63+
echo "Checking hello-microservice-consumer-openshift"
64+
cd hello-microservice-consumer-openshift
65+
mvn clean package > build.txt
66+
check
67+
cd ..
68+
69+
echo "Checking hello-microservice-openshift"
70+
cd hello-microservice-openshift
71+
mvn clean package > build.txt
72+
check
73+
cd ..
74+
75+
echo "Checking hello-microservice-consumer-openshift-circuit-breaker"
76+
cd hello-microservice-consumer-openshift-circuit-breaker
77+
mvn clean package > build.txt
78+
check
79+
cd ..
80+
81+
echo "Checking hello-microservice-openshift-health-checks"
82+
cd hello-microservice-openshift-health-checks
83+
mvn clean package > build.txt
84+
check
85+
cd ..
86+
87+
cd ..
88+
89+
echo "Checking RX"
90+
cd reactive-programming
91+
mvn clean package > build.txt
92+
check
93+
cd ..
94+
95+
# Packaging
96+
cd packaging-examples
97+
echo "Checking ant build"
98+
cd ant
99+
ant > build.txt
100+
check
101+
cd ..
102+
103+
echo "Checking gradle build"
104+
cd gradle
105+
./gradlew shadowJar > build.txt
106+
check
107+
cd ..
108+
109+
echo "Checking shade plugin build"
110+
cd maven-shade-plugin
111+
./mvnw clean package > build.txt
112+
check
113+
cd ..
114+
115+
echo "Checking vmp build"
116+
cd vertx-maven-plugin
117+
./mvnw clean package > build.txt
118+
check
119+
cd ..
120+
121+
echo "DONE"
122+
find . -name "build.txt" -exec rm -Rf {} \;
123+
124+
125+
126+
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>io.vertx.microservice</groupId>
7+
<artifactId>hello-consumer-microservice-http</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
10+
<properties>
11+
<vertx.version>3.4.0.Beta1</vertx.version>
12+
<fabric8-vertx-maven-plugin.version>1.0.4</fabric8-vertx-maven-plugin.version>
13+
14+
<vertx.verticle>io.vertx.book.http.HelloConsumerMicroservice</vertx.verticle>
15+
16+
<maven.compiler.source>1.8</maven.compiler.source>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
<maven.compiler.target>1.8</maven.compiler.target>
19+
</properties>
20+
21+
<dependencyManagement>
22+
<dependencies>
23+
<dependency>
24+
<groupId>io.vertx</groupId>
25+
<artifactId>vertx-dependencies</artifactId>
26+
<version>${vertx.version}</version>
27+
<type>pom</type>
28+
<scope>import</scope>
29+
</dependency>
30+
</dependencies>
31+
</dependencyManagement>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>io.vertx</groupId>
36+
<artifactId>vertx-core</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>io.vertx</groupId>
40+
<artifactId>vertx-web</artifactId>
41+
</dependency>
42+
<dependency>
43+
<groupId>io.vertx</groupId>
44+
<artifactId>vertx-web-client</artifactId>
45+
</dependency>
46+
<dependency>
47+
<groupId>io.vertx</groupId>
48+
<artifactId>vertx-rx-java</artifactId>
49+
</dependency>
50+
</dependencies>
51+
52+
<build>
53+
<plugins>
54+
<plugin>
55+
<groupId>io.fabric8</groupId>
56+
<artifactId>vertx-maven-plugin</artifactId>
57+
<version>${fabric8-vertx-maven-plugin.version}</version>
58+
<executions>
59+
<execution>
60+
<id>vmp</id>
61+
<goals>
62+
<goal>initialize</goal>
63+
<goal>package</goal>
64+
</goals>
65+
</execution>
66+
</executions>
67+
<configuration>
68+
<redeploy>true</redeploy>
69+
</configuration>
70+
</plugin>
71+
</plugins>
72+
</build>
73+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package io.vertx.book.http;
2+
3+
import io.vertx.rxjava.core.AbstractVerticle;
4+
import io.vertx.core.json.JsonObject;
5+
import io.vertx.rxjava.ext.web.Router;
6+
import io.vertx.rxjava.ext.web.RoutingContext;
7+
import io.vertx.rxjava.ext.web.client.HttpRequest;
8+
import io.vertx.rxjava.ext.web.client.HttpResponse;
9+
import io.vertx.rxjava.ext.web.client.WebClient;
10+
import io.vertx.rxjava.ext.web.codec.BodyCodec;
11+
import rx.Single;
12+
13+
public class HelloConsumerMicroservice extends AbstractVerticle {
14+
15+
private WebClient client;
16+
17+
@Override
18+
public void start() {
19+
client = WebClient.create(vertx);
20+
21+
Router router = Router.router(vertx);
22+
router.get("/").handler(this::invokeMyFirstMicroservice);
23+
24+
vertx.createHttpServer()
25+
.requestHandler(router::accept)
26+
.listen(8081);
27+
}
28+
29+
private void invokeMyFirstMicroservice(RoutingContext rc) {
30+
HttpRequest<JsonObject> request1 = client
31+
.get(8080, "localhost", "/Luke")
32+
.as(BodyCodec.jsonObject());
33+
34+
HttpRequest<JsonObject> request2 = client
35+
.get(8080, "localhost", "/Leia")
36+
.as(BodyCodec.jsonObject());
37+
38+
Single<HttpResponse<JsonObject>> s1 = request1.rxSend();
39+
Single<HttpResponse<JsonObject>> s2 = request2.rxSend();
40+
41+
Single.zip(s1, s2, (luke, leia) -> {
42+
// We have the result of both request in Luke and Leia
43+
return new JsonObject()
44+
.put("luke", luke.body().getString("message"))
45+
.put("leia", leia.body().getString("message"));
46+
}).subscribe(
47+
x -> {
48+
rc.response().end(x.encode());
49+
},
50+
t -> {
51+
rc.response().end(new JsonObject().encodePrettily());
52+
});
53+
}
54+
55+
}
+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>io.vertx.microservice</groupId>
7+
<artifactId>hello-consumer-microservice-message</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
10+
<properties>
11+
<vertx.version>3.4.0.Beta1</vertx.version>
12+
<fabric8-vertx-maven-plugin.version>1.0.4</fabric8-vertx-maven-plugin.version>
13+
14+
<vertx.verticle>io.vertx.book.message.HelloConsumerMicroservice</vertx.verticle>
15+
16+
<maven.compiler.source>1.8</maven.compiler.source>
17+
<maven.compiler.target>1.8</maven.compiler.target>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
</properties>
20+
21+
<dependencyManagement>
22+
<dependencies>
23+
<dependency>
24+
<groupId>io.vertx</groupId>
25+
<artifactId>vertx-dependencies</artifactId>
26+
<version>${vertx.version}</version>
27+
<type>pom</type>
28+
<scope>import</scope>
29+
</dependency>
30+
</dependencies>
31+
</dependencyManagement>
32+
<dependencies>
33+
<dependency>
34+
<groupId>io.vertx</groupId>
35+
<artifactId>vertx-core</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>io.vertx</groupId>
39+
<artifactId>vertx-infinispan</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>io.vertx</groupId>
43+
<artifactId>vertx-rx-java</artifactId>
44+
</dependency>
45+
</dependencies>
46+
47+
<build>
48+
<plugins>
49+
<plugin>
50+
<groupId>io.fabric8</groupId>
51+
<artifactId>vertx-maven-plugin</artifactId>
52+
<version>${fabric8-vertx-maven-plugin.version}</version>
53+
<executions>
54+
<execution>
55+
<id>vmp</id>
56+
<goals>
57+
<goal>initialize</goal>
58+
<goal>package</goal>
59+
</goals>
60+
</execution>
61+
</executions>
62+
<configuration>
63+
<redeploy>true</redeploy>
64+
</configuration>
65+
</plugin>
66+
</plugins>
67+
</build>
68+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.vertx.book.message;
2+
3+
import io.vertx.core.json.JsonObject;
4+
import io.vertx.rxjava.core.AbstractVerticle;
5+
import io.vertx.rxjava.core.eventbus.Message;
6+
import rx.Single;
7+
8+
public class HelloConsumerMicroservice extends AbstractVerticle {
9+
10+
@Override
11+
public void start() {
12+
vertx.createHttpServer()
13+
.requestHandler(
14+
req -> {
15+
Single<JsonObject> obs1 = vertx.eventBus()
16+
.<JsonObject>rxSend("hello", "Luke")
17+
.map(Message::body);
18+
Single<JsonObject> obs2 = vertx.eventBus()
19+
.<JsonObject>rxSend("hello", "Leia")
20+
.map(Message::body);
21+
22+
Single
23+
.zip(obs1, obs2, (luke, leia) ->
24+
new JsonObject()
25+
.put("Luke", luke.getString("message")
26+
+ " from " + luke.getString("served-by"))
27+
.put("Leia", leia.getString("message")
28+
+ " from " + leia.getString("served-by"))
29+
)
30+
.subscribe(
31+
x -> req.response().end(x.encodePrettily()),
32+
t -> req.response().setStatusCode(500).end(t.getMessage())
33+
);
34+
})
35+
.listen(8082);
36+
}
37+
38+
}

0 commit comments

Comments
 (0)