Skip to content

Commit 31393bb

Browse files
committed
Add README files with the instructions
1 parent 56be328 commit 31393bb

File tree

15 files changed

+425
-2
lines changed

15 files changed

+425
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ javadoc/
4040
build/
4141
lib/
4242

43+
*.idea/
44+
*.iml
4345

4446
*.pbxuser
4547
!default.pbxuser

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Reactive Microservices in Java
2+
3+
This repository contains the source code from the _Reactive Microsevices in Java - Asynchronous, Elastic, Resilience Applications_ book. It contains the source code shown in the book as well as other examples.
4+
5+
6+
The repository is structured as follows:
7+
8+
9+
* [Hello Vert.x - the Vert.x Hello World](hello-vertx)
10+
* [Packaging Examples - build Vert.x application using any tool](packaging-examples)
11+
* [Reactive Programming (RX Java 1) examples](reactive-programming)
12+
* [Microservices - the different microservices built in the book](microservices)
13+
* [OpenShift - the microservices built in the book running on top of OpenShift](openshift)
14+
15+
16+
Each directory contains the instructions to build and run the _module_.

microservices/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Microservices
2+
3+
This directory contains the different microservices developed in the book. In order of appearance:
4+
5+
* [Hello Microservice - HTTP](hello-microservice-http)
6+
* [Hello Consumer Microservice - HTTP](hello-consumer-microservice-http)
7+
* [Hello Microservice - Event Bus](hello-microservice-message)
8+
* [Hello Consumer Microservice - Event Bus](hello-consumer-microservice-message)
9+
* [Hello Microservice with faults](hello-microservice-faulty)
10+
* [Hello Consumer Microservice with timeout and reply](hello-consumer-microservice-timeout)
11+
12+
The _-consumer_ projects invoke the corresponding services:
13+
14+
* The [Hello Consumer Microservice - HTTP](hello-consumer-microservice-http) invokes the [Hello Microservice - HTTP](hello-microservice-http).
15+
* The [Hello Consumer Microservice - Event Bus](hello-consumer-microservice-message) invokes the [Hello Microservice - Event Bus](hello-microservice-message).
16+
* The [Hello Consumer Microservice with timeout and reply](hello-consumer-microservice-timeout) invokes the [Hello Microservice with faults](hello-microservice-faulty).
17+
18+
Be aware to run both at the same time.
19+
20+
Each project is built with Apache Maven:
21+
22+
```
23+
cd $DIRECTORY
24+
mvn clean package
25+
```
26+
27+
Each project contains a `README` with running instructions.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Hello Consumer Microservice - HTTP
2+
3+
This directory contains the source code of the _Hello_ microservice consumer using HTTP interactions. It invokes the [Hello microservice - HTTP](../hello-microservice-http).
4+
5+
## Running in development mode
6+
7+
8+
```
9+
mvn compile vertx:run
10+
```
11+
12+
Hit `CTRL+C` to stop the execution and reloading.
13+
14+
15+
## Packaging
16+
17+
```
18+
mvn clean package
19+
```
20+
21+
## Execution using the application package
22+
23+
```
24+
java -jar target/hello-consumer-microservice-http-1.0-SNAPSHOT.jar
25+
```
26+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Hello Consumer Microservice - Event Bus
2+
3+
This directory contains the source code of the _Hello_ microservice consumer using event bus (message) interactions. It invokes the [Hello microservice - Event Bus](../hello-microservice-message).
4+
5+
## Running in development mode
6+
7+
```
8+
mvn compile vertx:run -Dvertx.runArgs="-cluster -Djava.net.preferIPv4Stack=true"
9+
```
10+
11+
Hit `CTRL+C` to stop the execution and reloading.
12+
13+
14+
## Packaging
15+
16+
```
17+
mvn clean package
18+
```
19+
20+
## Execution using the application package
21+
22+
```
23+
java -jar target/hello-consumer-microservice-message-1.0-SNAPSHOT.jar -cluster -Djava.net.preferIPv4Stack=true
24+
```
25+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Hello Consumer Microservice - Event Bus with timeout and reply
2+
3+
This directory contains the source code of the _Hello_ microservice consumer using event bus (message) interactions. It implements a simple fault-tolerance strategy using timeouts and retries. It invokes the [Hello microservice - Event Bus - Faulty](../hello-microservice-faulty).
4+
5+
## Running in development mode
6+
7+
```
8+
mvn compile vertx:run -Dvertx.runArgs="-cluster -Djava.net.preferIPv4Stack=true"
9+
```
10+
11+
Hit `CTRL+C` to stop the execution and reloading.
12+
13+
14+
## Packaging
15+
16+
```
17+
mvn clean package
18+
```
19+
20+
## Execution using the application package
21+
22+
```
23+
java -jar target/hello-consumer-microservice-message-1.0-SNAPSHOT.jar -cluster -Djava.net.preferIPv4Stack=true
24+
```
25+

microservices/hello-consumer-microservice-timeout/src/main/java/io/vertx/book/message/HelloConsumerMicroservice.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ public void start() {
1919
<JsonObject>rxSend("hello", "Luke")
2020
.subscribeOn(RxHelper.scheduler(vertx))
2121
.timeout(3, TimeUnit.SECONDS)
22-
.retry()
22+
.retry((i, t) -> {
23+
System.out.println("Retrying... because of " + t.getMessage());
24+
return true;
25+
})
2326
.map(Message::body);
2427
Single<JsonObject> obs2 = vertx.eventBus().
2528
<JsonObject>rxSend("hello", "Leia")
2629
.subscribeOn(RxHelper.scheduler(vertx))
2730
.timeout(3, TimeUnit.SECONDS)
28-
.retry()
31+
.retry((i, t) -> {
32+
System.out.println("Retrying... because of " + t.getMessage());
33+
return true;
34+
})
2935
.map(Message::body);
3036

3137
Single
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Hello Microservice - Event Bus with faults
2+
3+
This directory contains the source code of the _Hello_ microservice using event bus (message) interactions with with injected fault (on purpose).
4+
5+
## Running in development mode
6+
7+
```
8+
mvn compile vertx:run -Dvertx.runArgs="-cluster -Djava.net.preferIPv4Stack=true"
9+
```
10+
11+
Hit `CTRL+C` to stop the execution and reloading.
12+
13+
14+
## Packaging
15+
16+
```
17+
mvn clean package
18+
```
19+
20+
## Execution using the application package
21+
22+
```
23+
java -jar target/hello-microservice-message-1.0-SNAPSHOT.jar -cluster -Djava.net.preferIPv4Stack=true
24+
```
25+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Hello Microservice - HTTP
2+
3+
This directory contains the source code of the _Hello_ microservice using HTTP interactions.
4+
5+
## Running in development mode
6+
7+
8+
```
9+
mvn compile vertx:run
10+
```
11+
12+
Hit `CTRL+C` to stop the execution and reloading.
13+
14+
15+
## Packaging
16+
17+
```
18+
mvn clean package
19+
```
20+
21+
## Execution using the application package
22+
23+
```
24+
java -jar target/hello-microservice-http-1.0-SNAPSHOT.jar
25+
```
26+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Hello Microservice - Event Bus
2+
3+
This directory contains the source code of the _Hello_ microservice using event bus (message) interactions.
4+
5+
## Running in development mode
6+
7+
```
8+
mvn compile vertx:run -Dvertx.runArgs="-cluster -Djava.net.preferIPv4Stack=true"
9+
```
10+
11+
Hit `CTRL+C` to stop the execution and reloading.
12+
13+
14+
## Packaging
15+
16+
```
17+
mvn clean package
18+
```
19+
20+
## Execution using the application package
21+
22+
```
23+
java -jar target/hello-microservice-message-1.0-SNAPSHOT.jar -cluster -Djava.net.preferIPv4Stack=true
24+
```
25+

0 commit comments

Comments
 (0)