Skip to content

Commit 72f442b

Browse files
committed
Merge branch 'release/4.8'
2 parents 3dc5e0a + 1ae5da4 commit 72f442b

File tree

33 files changed

+712
-461
lines changed

33 files changed

+712
-461
lines changed

README.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ Springy Store μService --> Parent folder.
2828
|- store-cloud-chassis --> Cloud services Parent POM, inherit from build contains all cloud libraries
2929
|- store-service-chassis --> Parent POM, inherits from cloud contains all microservices common libraries
3030
|-store-cloud-infra
31-
|- eureka-server --> Service discovery server
31+
|- eureka-server --> Service discovery server
32+
|- edge-server --> API Gateway server
3233
|-store-common
3334
|- store-api --> API Endpoint and services definitions for all microservices
3435
|- store-utils --> Common utilities shared between all components
@@ -66,7 +67,7 @@ The following topics are going to be covered in this 1st stage (other stages top
6667
- Adding automated tests of microservices in isolation.
6768
- Adding semi-automated tests to a microservice landscape.
6869

69-
### System Boundary - μServices Landscape (Release 4.5-Latest)
70+
### System Boundary - μServices Landscape (Release 4.8-Latest)
7071

7172
![System Boundary](docs/stage1/app_ms_landscape.png)
7273

@@ -158,7 +159,7 @@ All build commands and test suite for each microservice should run successfully,
158159

159160
```bash
160161
---------------< com.siriusxi.ms.store:store-aggregator >---------------
161-
[INFO] Building Springy Store Aggregator 1.0-SNAPSHOT [11/11]
162+
[INFO] Building Springy Store Aggregator 1.0-SNAPSHOT [12/12]
162163
[INFO] --------------------------------[ pom ]---------------------------------
163164
[INFO]
164165
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ store-aggregator ---
@@ -175,6 +176,7 @@ All build commands and test suite for each microservice should run successfully,
175176
[INFO] Recommendation Service ............................. SUCCESS [ 8.463 s]
176177
[INFO] Store Service ...................................... SUCCESS [ 8.927 s]
177178
[INFO] Eureka Discovery Server ............................ SUCCESS [ 6.536 s]
179+
[INFO] Edge Server ........................................ SUCCESS [ 32.108 s]
178180
[INFO] Springy Store Aggregator ........................... SUCCESS [ 0.100 s]
179181
[INFO] ------------------------------------------------------------------------
180182
[INFO] BUILD SUCCESS
@@ -198,6 +200,7 @@ All the **services**, **databases**, and **messaging service** will run in paral
198200
```bash
199201
Creating network "ssm_default" with the default driver
200202
Creating ssm_eureka_1 ... done
203+
Creating ssm_gateway_1 ... done
201204
Creating ssm_mysql_1 ... done
202205
Creating ssm_mongodb_1 ... done
203206
Creating ssm_rabbitmq_1 ... done
@@ -235,7 +238,7 @@ This will result in the following response:
235238
{
236239
"status":"UP",
237240
"components":{
238-
"Core System Microservices":{
241+
"System Microservices":{
239242
"status":"UP",
240243
"components":{
241244
"Product Service":{
@@ -278,7 +281,7 @@ The result will look like this:
278281
```bash
279282
Starting [Springy Store] full functionality testing....
280283
281-
Start: Sun, Apr 12, 2020 2:34:19 PM
284+
Start: Sun, Apr 30, 2020 2:34:19 PM
282285
HOST=localhost
283286
PORT=8080
284287
Wait for: curl http://localhost:8080/actuator/health ... Ok
@@ -302,13 +305,13 @@ Test OK (HTTP Code: 422, {"httpStatus":"UNPROCESSABLE_ENTITY","message":"Invalid
302305
Test OK (actual value: "Invalid productId: -1")
303306
Test OK (HTTP Code: 400, {"timestamp":"2020-04-12T12:34:26.471+00:00","path":"/store/api/v1/products/invalidProductId","status":400,"error":"Bad Request","message":"Type mismatch.","requestId":"044dcdf2-13"})
304307
Test OK (actual value: "Type mismatch.")
305-
End: Sun, Apr 12, 2020 2:34:26 PM
308+
End: Sun, Apr 30, 2020 2:34:26 PM
306309
```
307310
308311
### Closing The Story
309312
310-
Finally, to close the story, we will need to shut down Microservices manually service by service
311-
, hahaha just kidding, run the following script to shut down them all:
313+
Finally, to close the story, we need to shut down Microservices manually service by service
314+
, hahaha just kidding, run the following command to shut them all:
312315
313316
```bash
314317
mohamed.taman@DTLNV8 ~/springy-store-microservices
@@ -326,6 +329,7 @@ Stopping ssm_store_1 ... done
326329
Stopping ssm_mysql_1 ... done
327330
Stopping ssm_rabbitmq_1 ... done
328331
Stopping ssm_eureka_1 ... done
332+
Stopping ssm_gateway_1 ... done
329333
Removing ssm_recommendation_1 ... done
330334
Removing ssm_product_1 ... done
331335
Removing ssm_review_1 ... done
@@ -334,11 +338,11 @@ Removing ssm_store_1 ... done
334338
Removing ssm_mysql_1 ... done
335339
Removing ssm_rabbitmq_1 ... done
336340
Removing ssm_eureka_1 ... done
341+
Removing ssm_gateway_1 ... done
337342
Removing network ssm_default
338343
```
339344
### The End
340345
Happy coding :)
341346
342347
# License
343-
Copyright (C) 2017-2020 Mohamed Taman
344-
Licensed under the MIT License.
348+
Copyright (C) 2017-2020 Mohamed Taman, Licensed under the MIT License.

docker-compose-kafka.yml

+13-5
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ services:
9494
## Start - Store service definition
9595
store:
9696
build: store-services/store-service
97-
ports:
98-
- "8080:8080"
9997
environment:
10098
- SPRING_PROFILES_ACTIVE=docker
10199
- MANAGEMENT_HEALTH_RABBIT_ENABLED=false
@@ -115,10 +113,20 @@ services:
115113
## Start - Eureka Service Discovery definition
116114
eureka:
117115
build: store-cloud-infra/eureka-server
118-
ports:
119-
- "8761:8761"
120-
restart: always
116+
restart: on-failure
121117
## End - Eureka Service Discovery definition
118+
119+
## Start - Edge Server definition
120+
gateway:
121+
build: store-cloud-infra/edge-server
122+
ports:
123+
- "8080:8080"
124+
environment:
125+
- SPRING_PROFILES_ACTIVE=docker
126+
depends_on:
127+
- eureka
128+
restart: on-failure
129+
## End - Edge Server definition
122130
# End - Cloud Infrastructure
123131

124132
# Start - Data and transport Infrastructure

docker-compose-partitions.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ services:
8282
## Start - Store service definition
8383
store:
8484
build: store-services/store-service
85-
ports:
86-
- "8080:8080"
8785
environment:
8886
- SPRING_PROFILES_ACTIVE=docker
8987
- SPRING_CLOUD_STREAM_BINDINGS_OUTPUT-PRODUCTS_PRODUCER_PARTITION-KEY-EXPRESSION=payload.key
@@ -101,10 +99,20 @@ services:
10199
## Start - Eureka Service Discovery definition
102100
eureka:
103101
build: store-cloud-infra/eureka-server
104-
ports:
105-
- "8761:8761"
106102
restart: always
107103
## End - Eureka Service Discovery definition
104+
105+
## Start - Edge Server definition
106+
gateway:
107+
build: store-cloud-infra/edge-server
108+
ports:
109+
- "8080:8080"
110+
environment:
111+
- SPRING_PROFILES_ACTIVE=docker
112+
depends_on:
113+
- eureka
114+
restart: on-failure
115+
## End - Edge Server definition
108116
# End - Cloud Infrastructure
109117

110118
# Start - Data and transport Infrastructure

docker-compose.yml

+12-4
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ services:
3636
## Start - Store service definition
3737
store:
3838
build: store-services/store-service
39-
ports:
40-
- "8080:8080"
4139
environment:
4240
- SPRING_PROFILES_ACTIVE=docker
4341
depends_on:
@@ -49,10 +47,20 @@ services:
4947
## Start - Eureka Service Discovery definition
5048
eureka:
5149
build: store-cloud-infra/eureka-server
52-
ports:
53-
- "8761:8761"
5450
restart: on-failure
5551
## End - Eureka Service Discovery definition
52+
53+
## Start - Edge Server definition
54+
gateway:
55+
build: store-cloud-infra/edge-server
56+
ports:
57+
- "8080:8080"
58+
environment:
59+
- SPRING_PROFILES_ACTIVE=docker
60+
depends_on:
61+
- eureka
62+
restart: on-failure
63+
## End - Edge Server definition
5664
# End - Cloud Infrastructure
5765

5866
# Start - Data and transport Infrastructure

docs/stage1/app_ms_landscape.png

-31.7 KB
Loading
-109 KB
Binary file not shown.

pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<module>store-services/recommendation-service</module>
2828
<module>store-services/store-service</module>
2929
<module>store-cloud-infra/eureka-server</module>
30+
<module>store-cloud-infra/edge-server</module>
3031

3132

3233
</modules>

store-base/store-cloud-chassis/pom.xml

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
<packaging>pom</packaging>
1717

1818
<dependencies>
19+
<!-- Start - Core spring dependencies -->
20+
<!-- Start - Providing some useful infos about the service through REST API -->
21+
<dependency>
22+
<groupId>org.springframework.boot</groupId>
23+
<artifactId>spring-boot-starter-actuator</artifactId>
24+
</dependency>
25+
<!-- End - Providing some useful infos about the service through REST API -->
26+
<!-- Start - Cloud dependencies -->
1927
<!-- Start - Testing dependencies -->
2028
<dependency>
2129
<groupId>org.springframework.boot</groupId>

store-base/store-service-chassis/pom.xml

-8
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@
1717
<packaging>pom</packaging>
1818

1919
<dependencies>
20-
<!-- Start - Core spring dependencies -->
21-
<!-- Start - Providing some useful infos about the service through REST API -->
22-
<dependency>
23-
<groupId>org.springframework.boot</groupId>
24-
<artifactId>spring-boot-starter-actuator</artifactId>
25-
</dependency>
26-
<!-- End - Providing some useful infos about the service through REST API -->
27-
<!-- Start - Cloud dependencies -->
2820
<!-- Start - Spring Stream processing using "RabbitMQ massaging" -->
2921
<dependency>
3022
<groupId>org.springframework.cloud</groupId>
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#### Start of builder image
2+
# ------------------------
3+
# Builder stage to prepare application for final image
4+
FROM openjdk:14-slim-buster as builder
5+
WORKDIR temp
6+
7+
# Fatjar location, but could be set to different location from command line
8+
ARG JAR_FILE=target/*.jar
9+
10+
# Copy fat jar file to current image builder
11+
COPY ${JAR_FILE} application.jar
12+
13+
# Extract the jar file layers
14+
RUN java -Djarmode=layertools -jar --enable-preview application.jar extract
15+
16+
# Workaround to avoid Copy command failure when directory is not exists.
17+
RUN test ! -d ./snapshot-dependencies \
18+
&& mkdir snapshot-dependencies \
19+
&& echo "Directory [snapshot-dependencies] created."
20+
21+
#### End of builder stage
22+
23+
#### Start of actual image
24+
# ------------------------
25+
# Build image based on JDK 14 base image, based on latest debian buster OS
26+
FROM openjdk:14-slim-buster
27+
VOLUME /tmp
28+
29+
# Set image information, but could be set to different location from command line
30+
ARG IMAGE_VERSION="1.0-SNAPSHOT"
31+
ARG IMAGE_NAME="Edge Server"
32+
ARG MAINTAINER="Mohamed Taman <[email protected]>"
33+
34+
LABEL version=${IMAGE_VERSION} name=${IMAGE_NAME} maintainer=${MAINTAINER}
35+
36+
# Limiting security access to not user root user
37+
RUN addgroup siriusxi && useradd -g siriusxi -ms /bin/bash taman
38+
39+
# Setting user to current created user
40+
USER taman
41+
42+
# Set working directory to application folder
43+
WORKDIR /home/taman/application
44+
45+
# Copy all layers from builder stage to current image
46+
COPY --from=builder temp/dependencies/ ./
47+
COPY --from=builder temp/snapshot-dependencies/ ./
48+
COPY --from=builder temp/spring-boot-loader/ ./
49+
COPY --from=builder temp/application/ ./
50+
51+
# Expose current server to port 8080
52+
EXPOSE 8761
53+
54+
ARG JAVA_OPTS=""
55+
56+
# Run the application with JVM configs if any
57+
ENTRYPOINT ["bash", "-c", \
58+
"java -server --enable-preview -XX:+UseContainerSupport -XX:+ShowCodeDetailsInExceptionMessages \
59+
-XX:+AlwaysActAsServerClassMachine -XX:+UseG1GC -XX:+UseStringDeduplication ${JAVA_OPTS} \
60+
org.springframework.boot.loader.JarLauncher ${0} ${@}"]

store-cloud-infra/edge-server/pom.xml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>com.siriusxi.ms.store</groupId>
7+
<artifactId>store-cloud-chassis</artifactId>
8+
<version>1.0-SNAPSHOT</version>
9+
<relativePath>../store-base/store-cloud-chassis</relativePath>
10+
</parent>
11+
12+
<groupId>com.siriusxi.cloud.infra</groupId>
13+
<artifactId>gateway</artifactId>
14+
<version>1.0-SNAPSHOT</version>
15+
<name>Edge Server</name>
16+
<description>Spring Cloud API Gateway Server, based on Spring boot.</description>
17+
<packaging>jar</packaging>
18+
19+
<dependencies>
20+
<!-- Start - Spring cloud API Gateway server -->
21+
<dependency>
22+
<groupId>org.springframework.cloud</groupId>
23+
<artifactId>spring-cloud-starter-gateway</artifactId>
24+
</dependency>
25+
<!-- End - Spring cloud API Gateway server -->
26+
<!-- Start - To register API Gateway server with Eureka Discovery Server -->
27+
<dependency>
28+
<groupId>org.springframework.cloud</groupId>
29+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
30+
</dependency>
31+
<!-- End - To register API Gateway server with Eureka Discovery Server -->
32+
<!-- Start - Javax.validation is required to in order to test to work -->
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-validation</artifactId>
36+
<scope>runtime</scope>
37+
</dependency>
38+
<!-- End - Javax.validation is required to in order to test to work -->
39+
</dependencies>
40+
41+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.siriusxi.cloud.infra.gateway;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
6+
import org.springframework.context.annotation.Bean;
7+
import org.springframework.web.reactive.function.client.WebClient;
8+
9+
@SpringBootApplication
10+
public class EdgeServerApplication {
11+
12+
@Bean
13+
@LoadBalanced
14+
public WebClient.Builder loadBalancedWebClientBuilder() {
15+
return WebClient.builder();
16+
}
17+
18+
public static void main(String[] args) {
19+
SpringApplication.run(EdgeServerApplication.class, args);
20+
}
21+
22+
}

0 commit comments

Comments
 (0)