Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Feature/48 coordinator second phase implementation back #65

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,18 @@ mvn --projects :[module] spring-boot:run
### Use of API_GATEWAY and EUREKA_SERVER and MEDIATOR
To manage the microservices of the application, you need to first launch the module eureka_server (see the command above).
Then launch the module api_gateway and the module mediator.
You can have access to the Dashboard of the eureka_server at http://localhost:8761. You will see all the microservices.
You can have access to the Dashboard of the eureka_server at http://localhost:8080. You will see all the microservices.

Server port for the modules :
- EUREKA_SERVER : 8080
- API_GATEWAY : 9191
- MEDIATOR : 8081
- ACCOUNT : 8082
- BANK-DATABASE : 8083
- TRANSACTION : 8084
- PRODUCT : 8085
- SHOP-DATABASE : 8086
- ORDER : 8087

### For the endpoints documentation
You can access the documentation of each endpoints after launching at this address : http://<localhost:service port>/swagger-ui/index.html#. This page also allow you to try the different endpoints of the concerned service.
Expand Down
219 changes: 113 additions & 106 deletions Server/bank/account/pom.xml
Original file line number Diff line number Diff line change
@@ -1,106 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.cashmanager.server</groupId>
<artifactId>bank</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>account</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>account</name>
<description>account</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-docker-compose</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.cashmanager.server</groupId>
<artifactId>database</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.cashmanager.server</groupId>
<artifactId>common</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.cashmanager.server</groupId>
<artifactId>database</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<attach>false</attach>
</configuration>
</execution>
</executions>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.cashmanager.server</groupId>
<artifactId>bank</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>account</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>account</name>
<description>account</description>
<properties>
<java.version>17</java.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-docker-compose</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.cashmanager.server</groupId>
<artifactId>database</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.cashmanager.server</groupId>
<artifactId>common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<attach>false</attach>
</configuration>
</execution>
</executions>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>
7 changes: 7 additions & 0 deletions Server/bank/account/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Set the location of the database migration scripts
spring.flyway.locations=filesystem:../database/src/main/resources/db/migration

#Tomcat server port
server.port=8082

#Config for binding to the eureka-server
eureka.client.service-url.defaultZone=http://localhost:8080/eureka
spring.application.name=ACCOUNT-SERVICE
4 changes: 4 additions & 0 deletions Server/bank/database/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/bank_db
spring.datasource.username=bank_user
# postgresql database password
spring.datasource.password=bank_password

spring.application.name=BANK-DATABASE-SERVICE
#Tomcat server port
server.port=8083
16 changes: 16 additions & 0 deletions Server/bank/transaction/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@
<description>transaction</description>
<properties>
<java.version>17</java.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -61,6 +66,17 @@
<scope>compile</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# Set the location of the database migration scripts
spring.flyway.locations=filesystem:../database/src/main/resources/db/migration
#Tomcat server port
server.port=8084

#Config for binding to the eureka-server
eureka.client.service-url.defaultZone=http://localhost:8080/eureka
spring.application.name=TRANSACTION-SERVICE
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
spring.application.name=API-GATEWAY
server.port=9191
eureka.client.service-url.defaultZone=http://localhost:8761/eureka
eureka.client.service-url.defaultZone=http://localhost:8080/eureka
management.endpoints.web.exposure.include=*

#Routes Configuration
#spring.cloud.gateway.routes[0].id=SHOP-SERVICE
#spring.cloud.gateway.routes[0].uri=lb://SHOP-SERVICE
#spring.cloud.gateway.routes[0].predicates[0]=Path=/shop/**
spring.cloud.gateway.routes[0].id=MEDIATOR-SERVICE
spring.cloud.gateway.routes[0].uri=lb://MEDIATOR-SERVICE
spring.cloud.gateway.routes[0].predicates[0]=Path=/api/mediator/**

spring.cloud.gateway.routes[1].id=PRODUCT-SERVICE
spring.cloud.gateway.routes[1].uri=lb://PRODUCT-SERVICE
spring.cloud.gateway.routes[1].predicates[0]=Path=/api/shop/products/**

spring.cloud.gateway.routes[2].id=ORDER-SERVICE
spring.cloud.gateway.routes[2].uri=lb://ORDER-SERVICE
spring.cloud.gateway.routes[2].predicates[0]=Path=/api/shop/orders/**


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
spring.application.name=EUREKA-SERVER
server.port=8761
server.port=8080
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
5 changes: 4 additions & 1 deletion Server/coordinator/mediator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.cashmanager.server.mediator.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.client.WebClient;

@Configuration
public class WebClientConfig {
@Bean
public WebClient webClient() {

return WebClient.builder()
.baseUrl("http://localhost:9191/api")
.defaultCookie("cookie-name", "cookie-value")
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.build();
}
}
Loading
Loading