diff --git a/README.md b/README.md index cc098f02..284cfba5 100644 --- a/README.md +++ b/README.md @@ -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 *docker compose* 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: @@ -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.... @@ -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 @@ -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 ``` diff --git a/docker-compose-kafka.yml b/docker-compose-kafka.yml index 06780995..73eb6249 100644 --- a/docker-compose-kafka.yml +++ b/docker-compose-kafka.yml @@ -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: @@ -13,6 +15,7 @@ services: depends_on: - mongodb - kafka + ### Instance 2 product-i1: build: product-service environment: @@ -25,7 +28,10 @@ services: depends_on: - mongodb - kafka + ## End - Product service definition + ## Start - Recommendation service definition + ### Instance 1 recommendation: build: recommendation-service environment: @@ -38,6 +44,7 @@ services: depends_on: - mongodb - kafka + ### Instance 2 recommendation-i1: build: recommendation-service environment: @@ -50,7 +57,10 @@ services: depends_on: - mongodb - kafka + ## End - Recommendation service definition + ## Start - Review service definition + ### Instance 1 review: build: review-service environment: @@ -64,6 +74,7 @@ services: - mysql - kafka restart: on-failure + ### Instance 2 review-i1: build: review-service environment: @@ -77,7 +88,9 @@ services: - mysql - kafka restart: on-failure + ## End - Review service definition + ## Start - Store service definition store: build: store-service ports: @@ -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: @@ -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: @@ -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: @@ -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 \ No newline at end of file + restart: on-failure + ## End - Zookeeper cluster management service \ No newline at end of file diff --git a/docker-compose-partitions.yml b/docker-compose-partitions.yml index 366edee6..2851cb31 100644 --- a/docker-compose-partitions.yml +++ b/docker-compose-partitions.yml @@ -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: @@ -11,6 +13,7 @@ services: depends_on: - mongodb - rabbitmq + ### Instance 2 product-i1: build: product-service environment: @@ -21,7 +24,10 @@ services: depends_on: - mongodb - rabbitmq + ## End - Product service definition + ## Start - Recommendation service definition + ### Instance 1 recommendation: build: recommendation-service environment: @@ -32,6 +38,7 @@ services: depends_on: - mongodb - rabbitmq + ### Instance 2 recommendation-i1: build: recommendation-service environment: @@ -42,7 +49,10 @@ services: depends_on: - mongodb - rabbitmq + ## End - Recommendation service definition + ## Start - Review service definition + ### Instance 1 review: build: review-service environment: @@ -54,6 +64,7 @@ services: - mysql - rabbitmq restart: on-failure + ### Instance 2 review-i1: build: review-service environment: @@ -65,7 +76,9 @@ services: - mysql - rabbitmq restart: on-failure + ## End - Review service definition + ## Start - Store service definition store: build: store-service ports: @@ -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: @@ -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: @@ -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: @@ -124,3 +142,4 @@ services: timeout: 5s retries: 10 restart: on-failure + ## End - RabbitMQ Messaging service diff --git a/docker-compose.yml b/docker-compose.yml index 7511f81f..af37bd1c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ version: '3.7' ## Latest version works with Docker Engine release 18.06.0+ services: + ## Start - Product service definition product: build: product-service environment: @@ -8,7 +9,9 @@ services: depends_on: - mongodb - rabbitmq + ## End - Product service definition + ## Start - Recommendation service definition recommendation: build: recommendation-service environment: @@ -16,7 +19,9 @@ services: depends_on: - mongodb - rabbitmq + ## End - Recommendation service definition + ## Start - Review service definition review: build: review-service environment: @@ -25,7 +30,9 @@ services: - mysql - rabbitmq restart: on-failure + ## End - Review service definition + ## Start - Store service definition store: build: store-service ports: @@ -34,8 +41,10 @@ services: - SPRING_PROFILES_ACTIVE=docker depends_on: - rabbitmq + ## End - Store service definition - # $ mongo + ## Start - mongodb database definition + ### $ mongo mongodb: image: mongo:4.2.5-bionic ports: @@ -47,8 +56,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: @@ -65,8 +76,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: @@ -78,3 +90,4 @@ services: timeout: 5s retries: 10 restart: on-failure + ## End - RabbitMQ Messaging service