Skip to content

Commit

Permalink
Documenting changes and docker files for more readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamed-taman committed Apr 22, 2020
1 parent d791364 commit 4521fe7
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 20 deletions.
87 changes: 77 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,29 +156,94 @@ All build commands and test suite for each microservice should run successfully,
```

### Running Them All
Now it's the time to run all of them, and it's very simple just run the following *<u>docker compose</u>* commands:
#### Using RabbitMQ without the use of partitions
Now it's the time to run all of our reactive Microservices, and it's very simple just run the
following
`docker-compose` commands:

```bash
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ docker-compose -p ssm up -d
```

All the **services** and **databases** will run in parallel in detached mode (option `-d`), and their output will be printed to the console as the following:
All the **services**, **databases**, and **messaging service** will run in parallel in detach
mode
(option `-d`), and
command output will print to the console the following:

```bash
Creating network "ssm_default" with the default driver
Creating ssm_mysql_1 ... done
Creating ssm_mongodb_1 ... done
Creating ssm_store_1 ... done
Creating ssm_mysql_1 ... done
Creating ssm_mongodb_1 ... done
Creating ssm_rabbitmq_1 ... done
Creating ssm_store_1 ... done
Creating ssm_review_1 ... done
Creating ssm_product_1 ... done
Creating ssm_recommendation_1 ... done
```

### Access Store APIs
You can manually test `Store Service` APIs through out its **Swagger** interface at the following
You can manually test `Store Service` APIs throughout its **Swagger** interface at the following
URL [http://localhost:8080/swagger-ui.html](http://localhost:8080/swagger-ui.html).

#### Access RabbitMQ
In browser point to this URL [http://localhost:5672/](http://localhost:5672/) `username: guest
` and `password: guest`, and you can see all **topics**, **DLQs**, **partitions**, and payload.

1. For running 2 instances of each service and using _RabbitMQ with two partitions per topic_, use
the following
`docker-compose` command:
```bash
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ docker-compose -p ssm -f docker-compose-partitions.yml up -d
```
1. To use _Kafka and Zookeeper with two partitions per topic_ run the following
command:
```bash
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ docker-compose -p ssm -f docker-compose-kafka.yml up -d
```

#### Check All Services Health
From Store front Service we can check all the core services health, when you have all the
microservices up and running using Docker Compose,
```bash
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ curl http://localhost:8080/actuator/health -s | jq .
```
This will result in the following response:
```json
{
"status":"UP",
"components":{
"Core System Microservices":{
"status":"UP",
"components":{
"Product Service":{
"status":"UP"
},
"Recommendation Service":{
"status":"UP"
},
"Review Service":{
"status":"UP"
}
}
},
"diskSpace":{
"status":"UP",
"details":{
"total":255382777856,
"free":86618931200,
"threshold":10485760,
"exists":true
}
},
"ping":{
"status":"UP"
}
}
}
```
### Testing Them All
Now it's time to test all the application functionality as one part. To do so just run
the following automation test script:
Expand All @@ -188,7 +253,7 @@ mohamed.taman@DTLNV8 ~/springy-store-microservices
λ ./test-em-all.sh
```

The result should be something like this:
The result will look like this:

```bash
Starting [Springy Store] full functionality testing....
Expand Down Expand Up @@ -227,10 +292,10 @@ Finally, to close the story, we will need to shut down Microservices manually se

```bash
mohamed.taman@DTLNV8 ~/springy-store-microservices
λ docker-compose -p ssm down
λ docker-compose -p ssm down --remove-orphans
```

And the output should be as the following:
And you should see output like the following:

```bash
Stopping ssm_recommendation_1 ... done
Expand All @@ -239,12 +304,14 @@ Stopping ssm_review_1 ... done
Stopping ssm_mongodb_1 ... done
Stopping ssm_store_1 ... done
Stopping ssm_mysql_1 ... done
Stopping ssm_rabbitmq_1 ... done
Removing ssm_recommendation_1 ... done
Removing ssm_product_1 ... done
Removing ssm_review_1 ... done
Removing ssm_mongodb_1 ... done
Removing ssm_store_1 ... done
Removing ssm_mysql_1 ... done
Removing ssm_rabbitmq_1 ... done
Removing network ssm_default
```

Expand Down
29 changes: 25 additions & 4 deletions docker-compose-kafka.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
version: '3.7' ## Latest version works with Docker Engine release 18.06.0+

services:
## Start - Product service definition
### Instance 1
product:
build: product-service
environment:
Expand All @@ -13,6 +15,7 @@ services:
depends_on:
- mongodb
- kafka
### Instance 2
product-i1:
build: product-service
environment:
Expand All @@ -25,7 +28,10 @@ services:
depends_on:
- mongodb
- kafka
## End - Product service definition

## Start - Recommendation service definition
### Instance 1
recommendation:
build: recommendation-service
environment:
Expand All @@ -38,6 +44,7 @@ services:
depends_on:
- mongodb
- kafka
### Instance 2
recommendation-i1:
build: recommendation-service
environment:
Expand All @@ -50,7 +57,10 @@ services:
depends_on:
- mongodb
- kafka
## End - Recommendation service definition

## Start - Review service definition
### Instance 1
review:
build: review-service
environment:
Expand All @@ -64,6 +74,7 @@ services:
- mysql
- kafka
restart: on-failure
### Instance 2
review-i1:
build: review-service
environment:
Expand All @@ -77,7 +88,9 @@ services:
- mysql
- kafka
restart: on-failure
## End - Review service definition

## Start - Store service definition
store:
build: store-service
ports:
Expand All @@ -94,8 +107,10 @@ services:
- SPRING_CLOUD_STREAM_BINDINGS_OUTPUT-REVIEWS_PRODUCER_PARTITION-COUNT=2
depends_on:
- kafka
## End - Store service definition

# $ mongo
## Start - mongodb database definition
### $ mongo
mongodb:
image: mongo:4.2.5-bionic
ports:
Expand All @@ -107,8 +122,10 @@ services:
retries: 5
start_period: 40s
restart: on-failure
## End - mongodb database definition

# $ mysql -uroot -h127.0.0.1 -p
## Start - MySql database definition
### $ mysql -uroot -h127.0.0.1 -p
mysql:
image: mysql:8.0.19
ports:
Expand All @@ -125,8 +142,9 @@ services:
timeout: 5s
retries: 10
restart: on-failure
## End - MySql database definition

# Kafka Messaging service
## Start - Kafka Messaging service
kafka:
image: wurstmeister/kafka:latest
ports:
Expand All @@ -138,11 +156,14 @@ services:
depends_on:
- zookeeper
restart: on-failure
## End - Kafka Messaging service

## Start - Zookeeper (Kafka) cluster management service
zookeeper:
image: wurstmeister/zookeeper:latest
ports:
- "2181:2181"
environment:
- KAFKA_ADVERTISED_HOST_NAME=zookeeper
restart: on-failure
restart: on-failure
## End - Zookeeper cluster management service
25 changes: 22 additions & 3 deletions docker-compose-partitions.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
version: '3.7' ## Latest version works with Docker Engine release 18.06.0+

services:
## Start - Product service definition
### Instance 1
product:
build: product-service
environment:
Expand All @@ -11,6 +13,7 @@ services:
depends_on:
- mongodb
- rabbitmq
### Instance 2
product-i1:
build: product-service
environment:
Expand All @@ -21,7 +24,10 @@ services:
depends_on:
- mongodb
- rabbitmq
## End - Product service definition

## Start - Recommendation service definition
### Instance 1
recommendation:
build: recommendation-service
environment:
Expand All @@ -32,6 +38,7 @@ services:
depends_on:
- mongodb
- rabbitmq
### Instance 2
recommendation-i1:
build: recommendation-service
environment:
Expand All @@ -42,7 +49,10 @@ services:
depends_on:
- mongodb
- rabbitmq
## End - Recommendation service definition

## Start - Review service definition
### Instance 1
review:
build: review-service
environment:
Expand All @@ -54,6 +64,7 @@ services:
- mysql
- rabbitmq
restart: on-failure
### Instance 2
review-i1:
build: review-service
environment:
Expand All @@ -65,7 +76,9 @@ services:
- mysql
- rabbitmq
restart: on-failure
## End - Review service definition

## Start - Store service definition
store:
build: store-service
ports:
Expand All @@ -80,8 +93,10 @@ services:
- SPRING_CLOUD_STREAM_BINDINGS_OUTPUT-REVIEWS_PRODUCER_PARTITION-COUNT=2
depends_on:
- rabbitmq
## End - Store service definition

# $ mongo
## Start - mongodb database definition
### $ mongo
mongodb:
image: mongo:4.2.5-bionic
ports:
Expand All @@ -93,8 +108,10 @@ services:
retries: 5
start_period: 40s
restart: on-failure
## End - mongodb database definition

# $ mysql -uroot -h127.0.0.1 -p
## Start - MySql database definition
### $ mysql -uroot -h127.0.0.1 -p
mysql:
image: mysql:8.0.19
ports:
Expand All @@ -111,8 +128,9 @@ services:
timeout: 5s
retries: 10
restart: on-failure
## End - MySql database definition

# RabbitMQ Messaging service
## Start - RabbitMQ Messaging service
rabbitmq:
image: rabbitmq:3.8.3-management
ports:
Expand All @@ -124,3 +142,4 @@ services:
timeout: 5s
retries: 10
restart: on-failure
## End - RabbitMQ Messaging service
Loading

0 comments on commit 4521fe7

Please sign in to comment.