Skip to content

Commit 8eafe69

Browse files
committed
Merge branch 'release/4.5'
2 parents 5467a65 + 93a5dba commit 8eafe69

File tree

36 files changed

+785
-372
lines changed

36 files changed

+785
-372
lines changed

README.md

+74-55
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,56 @@
11
# Springy Store μServices
22

3-
- This project is a development of a small set of Spring Boot based Microservices projects, that implement cloud-native intuitive, design patterns and coding best practices.
3+
- This project is a development of a small set of **Spring Boot** and **Cloud** based Microservices projects, that implement cloud-native intuitive, Reactive Programming, Event-driven, Microservices design patterns and coding best practices.
44
- The project follows [**CloudNative**](https://www.cncf.io/) recommendations and The [**twelve-factor app**](https://12factor.net/) methodology for building *software-as-a-service apps* to show how μServices should be built and deployed.
5-
- The project is using cutting edge technologies like Docker, Kubernetes, Elasticsearch Stack for logging and monitoring, Java SE 14, MySQL database, MongoDB, TDD, unit, integration & performance testing and Reactive Programming, and many more.
5+
- This project is using cutting edge technologies like Docker, Kubernetes, Elasticsearch Stack for logging and monitoring, Java SE 14, MySQL, and MongoDB databases, all components developed with TDD in mind, covering integration & performance testing, and many more.
66

77
------
8-
98
I am developing this project as stages, and all such stages are documented under project
10-
**Springy Store μServices** [wiki page](https://github.com/mohamed-taman/Springy-Store-Microservices/wiki). Each of such stage will be a release in its owen, so you can go back and
11-
forward
12-
between releases to see the differences and how adding things solve specific problems we face.
9+
**Springy Store μServices** [wiki page](https://github.com/mohamed-taman/Springy-Store-Microservices/wiki). Each of such stage will be a release in its own, so you can go back and
10+
forward between releases to see the differences and how adding things solve specific problems we face.
1311

14-
For example; in the first stage (1st release) I just created project structure, basic services' skeleton, integration between them, and finally write integration testing as well as semi-automated testing for the whole services' functionality.
12+
<u>For example;</u> in the first stage (1st release) I just created project structure, basic services' skeleton, integration between them, and finally write integration testing as well as semi-automated testing for the whole services' functionality.
1513

16-
At 1st stage the **Recommendation** and **Review** microservices generate local in-memory data
17-
and **Store Service** calls the other three services (*Product*, *Recommendation*, and *Review*) statically to generate client aggregate response for a specific product. Therefore, in:
14+
At the 1st stage the **Recommendation** and **Review** microservices generate local in-memory data and **Store Service** calls the other three services (*Product*, *Recommendation*, and *Review*) statically to generate client aggregate response for a specific product. Therefore, in:
1815

1916
- The second stage I will introduce **database integration**, then in (***done***)
2017
- The third stage I will introduce **Dockerization** of our services and **docker-compose**, and in (***done***)
2118
- The fourth stage I will introduce **service discovery**, and so on.
2219

20+
## System components Structure
21+
Let's explain first the system structure to understand its components:
22+
**Springy Store μService** --> *Parent folder.*
23+
|- **config** --> *All system configuration files*
24+
|- **docs** --> *All docs and diagrams.*
25+
|- **store-base**
26+
|- **store-build-chassis** --> *Super Parent POM, contains all build information*
27+
|- **store-cloud-chassis** --> *Cloud services Parent POM, inherit from build contains all cloud libraries*
28+
|- **store-service-chassis** --> *Parent POM, inherits from cloud contains all microservices common libraries*
29+
|-**store-cloud-infra**
30+
|- **eureka-server** --> *Service discovery server*
31+
|-**store-common**
32+
|- **store-api** --> *API Endpoint and services definitions for all microservices*
33+
|- **store-utils** --> *Common utilities shared between all components*
34+
|-**store-services**
35+
|- **product-service** --> *Product Microservice*
36+
|- **recommendation-service** --> *Recommendation Microservice*
37+
|- **review-service** --> *Review Microservice*
38+
|- **store-service** --> *Store Microservice*
39+
|- **docker-compose.yml** --> *contains all services landscape with RabbitMQ*
40+
|- **docker-compose-kafka.yml** --> *contains all services landscape with more instances working with Kafka with partitions*
41+
|- **docker-compose-partitions.yml** *--> contains all services landscape with more instances working with RabbitMQ with partitions*
42+
|- **run-em-all.sh** *--> Run all microservices in separate mode.*
43+
|- **setup.sh** *--> Install all shared POMs and shared libraries.*
44+
|- **stop-em-all.sh** *--> Stop all services runs in standalone mode.*
45+
|- **test-em-all.sh** *--> This will start all docker compose landscape and test them, then shutdown docker compose containers with test finishes (use switch start stop)*
46+
47+
Now as we have learned about different system components, then let's start.
48+
2349
## Getting started
2450

2551
The first stage aka (**Release v1.0**) is about creating and implementing a set of project Microservices.
2652

27-
### Creating a Set of Cooperating Microservices
53+
### Creating a Set of Cooperating Microservices (Release v1.0)
2854

2955
The following topics are going to be covered in this 1st stage (other stages topics to be documented
3056
in a
@@ -39,7 +65,7 @@ The following topics are going to be covered in this 1st stage (other stages top
3965
- Adding automated tests of microservices in isolation.
4066
- Adding semi-automated tests to a microservice landscape.
4167

42-
### System Boundary - μServices Landscape (Release 4)
68+
### System Boundary - μServices Landscape (Release 4.5-Latest)
4369

4470
![System Boundary](docs/stage1/app_ms_landscape.png)
4571

@@ -85,11 +111,9 @@ To build and run test cases for each service & shared modules in the project we
85111

86112
#### First: Build & Install Shared Dependencies
87113

88-
> This done only for the first time or any new version of shared modules.
114+
> This done only for the first time or any new changes or versions of shared modules and POMs.
89115
90-
To build and install `store-build-chassis`, `store-utils`, `store-api`, `store-chassis` libraries
91-
, from the root
92-
folder `springy-store-microservices` run the following commands:
116+
To build and install `store-build-chassis`, `store-utils`, `store-api`, `store-chassis` libraries, from the root folder `springy-store-microservices` run the following commands:
93117

94118
```bash
95119
mohamed.taman@DTLNV8 ~/springy-store-microservices
@@ -99,25 +123,27 @@ mohamed.taman@DTLNV8 ~/springy-store-microservices
99123
Now you should expect output like this:
100124

101125
```bash
102-
Installing all Springy store core shared modules
103-
................................................
126+
Installing all Springy store core shared modules & Parent POMs
127+
...............................................................
104128

105129
1- Installing [Parent Build Chassis] module...
106130
Done successfully.
107131

108-
2- Installing shared [Services Utilities] module...
132+
2- Installing [Parent Cloud Chassis] module...
109133
Done successfully.
110134

111-
3- Installing shared [Services APIs] module...
135+
3- Installing shared [Services Utilities] module...
112136
Done successfully.
113137

114-
4- Installing [Services Parent Chassis] module...
138+
4- Installing shared [Services APIs] module...
139+
Done successfully.
140+
141+
5- Installing [Services Parent Chassis] module...
115142
Done successfully.
116143

117144
Woohoo, building & installing all project modules are finished successfully.
118145
The project is ready for the next step. :)
119146
```
120-
121147
#### Second: Build & Test Microservices
122148
Now it is time to build our **4 microservices** and run each service integration test in
123149
isolation by running the following commands:
@@ -130,49 +156,47 @@ mohamed.taman@DTLNV8 ~/springy-store-microservices
130156
All build commands and test suite for each microservice should run successfully, and the final output should be like this:
131157

132158
```bash
133-
[INFO] ---------------< com.siriusxi.ms.store:store-aggregator >---------------
134-
[INFO] Building Springy Store Aggregator 1.0-SNAPSHOT [9/9]
159+
---------------< com.siriusxi.ms.store:store-aggregator >---------------
160+
[INFO] Building Springy Store Aggregator 1.0-SNAPSHOT [11/11]
135161
[INFO] --------------------------------[ pom ]---------------------------------
136162
[INFO]
137163
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ store-aggregator ---
138164
[INFO] ------------------------------------------------------------------------
139165
[INFO] Reactor Summary for Springy Store Aggregator 1.0-SNAPSHOT:
140166
[INFO]
141-
[INFO] Springy Store Build Chassis ........................ SUCCESS [ 0.276 s]
142-
[INFO] Springy Store APIs ................................. SUCCESS [ 3.920 s]
143-
[INFO] Springy Store Utils ................................ SUCCESS [ 1.508 s]
144-
[INFO] Springy Store Chassis .............................. SUCCESS [ 0.608 s]
145-
[INFO] Store Service ...................................... SUCCESS [ 4.073 s]
146-
[INFO] Product Service .................................... SUCCESS [ 2.710 s]
147-
[INFO] Review Service ..................................... SUCCESS [ 2.633 s]
148-
[INFO] Recommendation Service ............................. SUCCESS [ 2.615 s]
149-
[INFO] Springy Store Aggregator ........................... SUCCESS [ 0.071 s]
167+
[INFO] Springy Store Build Chassis ........................ SUCCESS [ 0.228 s]
168+
[INFO] Springy Store Cloud Chassis ........................ SUCCESS [ 1.257 s]
169+
[INFO] Store APIs ......................................... SUCCESS [ 4.279 s]
170+
[INFO] Store Utils ........................................ SUCCESS [ 1.809 s]
171+
[INFO] Springy Store Chassis .............................. SUCCESS [ 0.857 s]
172+
[INFO] Product Service .................................... SUCCESS [ 13.079 s]
173+
[INFO] Review Service ..................................... SUCCESS [ 9.332 s]
174+
[INFO] Recommendation Service ............................. SUCCESS [ 8.463 s]
175+
[INFO] Store Service ...................................... SUCCESS [ 8.927 s]
176+
[INFO] Eureka Discovery Server ............................ SUCCESS [ 6.536 s]
177+
[INFO] Springy Store Aggregator ........................... SUCCESS [ 0.100 s]
150178
[INFO] ------------------------------------------------------------------------
151179
[INFO] BUILD SUCCESS
152180
[INFO] ------------------------------------------------------------------------
153-
[INFO] Total time: 18.900 s
154-
[INFO] Finished at: 2020-04-09T01:33:14+02:00
181+
[INFO] Total time: 55.663 s
182+
[INFO] Finished at: 2020-04-26T03:38:34+02:00
155183
[INFO] ------------------------------------------------------------------------
156184
```
157185

158186
### Running Them All
159187
#### Using RabbitMQ without the use of partitions
160-
Now it's the time to run all of our reactive Microservices, and it's very simple just run the
161-
following
162-
`docker-compose` commands:
188+
Now it's the time to run all of our reactive Microservices, and it's very simple just run the following `docker-compose` commands:
163189

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

169-
All the **services**, **databases**, and **messaging service** will run in parallel in detach
170-
mode
171-
(option `-d`), and
172-
command output will print to the console the following:
195+
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:
173196

174197
```bash
175198
Creating network "ssm_default" with the default driver
199+
Creating ssm_eureka_1 ... done
176200
Creating ssm_mysql_1 ... done
177201
Creating ssm_mongodb_1 ... done
178202
Creating ssm_rabbitmq_1 ... done
@@ -186,23 +210,18 @@ Creating ssm_recommendation_1 ... done
186210
You can manually test `Store Service` APIs throughout its **Swagger** interface at the following
187211
URL [http://localhost:8080/swagger-ui.html](http://localhost:8080/swagger-ui.html).
188212
#### Access RabbitMQ
189-
In browser point to this URL [http://localhost:5672/](http://localhost:5672/) `username: guest
190-
` and `password: guest`, and you can see all **topics**, **DLQs**, **partitions**, and payload.
213+
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.
191214

192-
1. For running 2 instances of each service and using _RabbitMQ with two partitions per topic_, use
193-
the following
194-
`docker-compose` command:
215+
1. For running 2 instances of each service and using _RabbitMQ with two partitions per topic_, use the following `docker-compose` command:
195216
```bash
196217
mohamed.taman@DTLNV8 ~/springy-store-microservices
197218
λ docker-compose -p ssm -f docker-compose-partitions.yml up -d
198219
```
199-
1. To use _Kafka and Zookeeper with two partitions per topic_ run the following
200-
command:
201-
```bash
220+
1. To use _Kafka and Zookeeper with two partitions per topic_ run the following command:
221+
```bash
202222
mohamed.taman@DTLNV8 ~/springy-store-microservices
203223
λ docker-compose -p ssm -f docker-compose-kafka.yml up -d
204-
```
205-
224+
```
206225
#### Check All Services Health
207226
From Store front Service we can check all the core services health, when you have all the
208227
microservices up and running using Docker Compose,
@@ -250,7 +269,7 @@ Now it's time to test all the application functionality as one part. To do so ju
250269
251270
```bash
252271
mohamed.taman@DTLNV8 ~/springy-store-microservices
253-
λ ./test-em-all.sh
272+
λ ./test-em-all.sh start stop
254273
```
255274
256275
The result will look like this:
@@ -305,20 +324,20 @@ Stopping ssm_mongodb_1 ... done
305324
Stopping ssm_store_1 ... done
306325
Stopping ssm_mysql_1 ... done
307326
Stopping ssm_rabbitmq_1 ... done
327+
Stopping ssm_eureka_1 ... done
308328
Removing ssm_recommendation_1 ... done
309329
Removing ssm_product_1 ... done
310330
Removing ssm_review_1 ... done
311331
Removing ssm_mongodb_1 ... done
312332
Removing ssm_store_1 ... done
313333
Removing ssm_mysql_1 ... done
314334
Removing ssm_rabbitmq_1 ... done
335+
Removing ssm_eureka_1 ... done
315336
Removing network ssm_default
316337
```
317-
318338
### The End
319339
Happy coding :)
320340
321341
# License
322342
Copyright (C) 2017-2020 Mohamed Taman
323-
324-
Licensed under the MIT License.
343+
Licensed under the MIT License.

docker-compose-kafka.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: '3.7' ## Latest version works with Docker Engine release 18.06.0+
22

33
services:
4+
# Start - Core Microservices
45
## Start - Product service definition
56
### Instance 1
67
product:
@@ -108,7 +109,19 @@ services:
108109
depends_on:
109110
- kafka
110111
## End - Store service definition
112+
# End - Core Microservices
111113

114+
# Start - Cloud Infrastructure
115+
## Start - Eureka Service Discovery definition
116+
eureka:
117+
build: store-cloud-infra/eureka-server
118+
ports:
119+
- "8761:8761"
120+
restart: always
121+
## End - Eureka Service Discovery definition
122+
# End - Cloud Infrastructure
123+
124+
# Start - Data and transport Infrastructure
112125
## Start - mongodb database definition
113126
### $ mongo
114127
mongodb:
@@ -166,4 +179,5 @@ services:
166179
environment:
167180
- KAFKA_ADVERTISED_HOST_NAME=zookeeper
168181
restart: on-failure
169-
## End - Zookeeper cluster management service
182+
## End - Zookeeper cluster management service
183+
# End - Data and transport Infrastructure

docker-compose-partitions.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: '3.7' ## Latest version works with Docker Engine release 18.06.0+
22

33
services:
4+
# Start - Core Microservices
45
## Start - Product service definition
56
### Instance 1
67
product:
@@ -94,7 +95,19 @@ services:
9495
depends_on:
9596
- rabbitmq
9697
## End - Store service definition
98+
# End - Core Microservices
9799

100+
# Start - Cloud Infrastructure
101+
## Start - Eureka Service Discovery definition
102+
eureka:
103+
build: store-cloud-infra/eureka-server
104+
ports:
105+
- "8761:8761"
106+
restart: always
107+
## End - Eureka Service Discovery definition
108+
# End - Cloud Infrastructure
109+
110+
# Start - Data and transport Infrastructure
98111
## Start - mongodb database definition
99112
### $ mongo
100113
mongodb:
@@ -143,3 +156,4 @@ services:
143156
retries: 10
144157
restart: on-failure
145158
## End - RabbitMQ Messaging service
159+
# End - Data and transport Infrastructure

docker-compose.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: '3.7' ## Latest version works with Docker Engine release 18.06.0+
22

33
services:
4+
# Start - Core Microservices
45
## Start - Product service definition
56
product:
67
build: store-services/product-service
@@ -42,7 +43,19 @@ services:
4243
depends_on:
4344
- rabbitmq
4445
## End - Store service definition
46+
# End - Core Microservices
4547

48+
# Start - Cloud Infrastructure
49+
## Start - Eureka Service Discovery definition
50+
eureka:
51+
build: store-cloud-infra/eureka-server
52+
ports:
53+
- "8761:8761"
54+
restart: on-failure
55+
## End - Eureka Service Discovery definition
56+
# End - Cloud Infrastructure
57+
58+
# Start - Data and transport Infrastructure
4659
## Start - mongodb database definition
4760
### $ mongo
4861
mongodb:
@@ -91,3 +104,4 @@ services:
91104
retries: 10
92105
restart: on-failure
93106
## End - RabbitMQ Messaging service
107+
# End - Data and transport Infrastructure

docs/stage1/app_ms_landscape.png

-57.2 KB
Loading

pom.xml

+8-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717
</properties>
1818

1919
<modules>
20+
<module>store-base/store-build-chassis</module>
21+
<module>store-base/store-cloud-chassis</module>
22+
<module>store-base/store-service-chassis</module>
23+
<module>store-common/store-api</module>
24+
<module>store-common/store-utils</module>
2025
<module>store-services/product-service</module>
2126
<module>store-services/review-service</module>
2227
<module>store-services/recommendation-service</module>
2328
<module>store-services/store-service</module>
24-
<module>store-common/store-api</module>
25-
<module>store-common/store-utils</module>
26-
<module>store-base/store-build-chassis</module>
27-
<module>store-base/store-service-chassis</module>
29+
<module>store-cloud-infra/eureka-server</module>
30+
31+
2832
</modules>
2933
</project>

0 commit comments

Comments
 (0)