This project based on SERVLET STACK and using Spring Boot 2.0.4.RELEASE and Spring Cloud Finchley.RELEASE
- Service Discovery
- Api Gateway
- User Service Consumer
- User Service Producer
- Spring Boot Admin
Service discovery is the automatic detection of devices and services offered by these devices on a computer network.
- Netflix Eureka Server
mvn clean install
mvn spring-boot:run
server is running on port 8761
The wrapper of services
- Netflix Zuul Proxy
- OAuth2 Server (JDBC for client detail & Redis for store token)
- Api Documentation (Swagger)
mvn clean install
mvn spring-boot:run
server is running on port 9000
Swagger UI URL = http://localhost:9000/swagger-ui.html swagger resource is manually added on SwaggerConfig.java
Consume service from producer using load balancer, monitoring service usage on Hystrix Dashboard, Circuit Breaker when producer is down
- Ribbon Load balancer (Rest Template & Open Feign)
- Hystrix Dashboard
- Circuit Breaker with fallback method
- Cache service (ehcache)
- Swagger Resource
mvn clean install
mvn spring-boot:run
server is running on port 9999
Hystrix Dashboard URL = http://localhost:9999/hystrix
Hystrix Stream URL = http://localhost:9999/actuator/hystrix.stream
The main service that connected to database for transfering data
- Mongo DB
- Mongo Repository like a JPA
mvn clean install
mvn spring-boot:run
server is running on port 9998
Monitoring your microservice
- Spring Boot Admin
mvn clean install
mvn spring-boot:run
server is running on port 9995
Spring Boot Admin URL = http://localhost:9995
spring boot admin connect to eureka server and using instance service from eureka server
Header Authorization: Bearer token
must be included in any request
Request
Http Method : POST
URL : http://localhost:9000/oauth/token
Header : Authorization: Basic auth, Content-Type: application/x-www-form-urlencoded
Body : grant_type: client_credentials
Response
{
"access_token": "c4472fb0-3401-42fe-91c2-65e5627455ed",
"token_type": "bearer",
"expires_in": 286,
"scope": "read write"
}
Http Method : GET
Header : Authorization: Bearer c4472fb0-3401-42fe-91c2-65e5627455ed
URL: http://localhost:9000/api/user-service/getall
- localhost:9000 is host api gateway
- /api/user-service is path between api gateway and user service consumer
- /getall is path from user service consumer
- Header from response get token