Microservice Authorization server - Resource Server - Gateway
Authentication server using asymmetric
- Import database
- Generate keypair
------------ Branch Master -----------------
Used Jwt token store. Token generated store in memory.
------------ Branch oauth2-server-jdbc -----------------
Used Jwt token store. Token generated store in database.
------------ Branch oauth2-server-jwt ------
Used Jwt token store. Token generated store in memory.
- Resource Service: Skeleton code for Resource Server
- Order Service, Delivery Service,... is resource server
- Eureka server
- Gateway discovery service
- Spring cloud config for properties
- Common for Role Base Access Control
- Common Util: Util method
- Common Dto: DTO class
- Common Entity: Entity mapping from database
-
MySQL
-
Database per service
-
Transaction rollback following Sagas pattern
-
PostgreSQL: One database with multiple schemas
- database: postgreSQL
- schemas: delivery_db, auditor_db,...
zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties & kafka-server-start /usr/local/etc/kafka/server.properties
- using Kafka or Rest : done
Delivery Service: Delivery changed status delivered send an event to Order Service: http://localhost:8766/delivery-service/v1/delivery/delivered
Order Service: delete order send an event to Delivery Service for cancel delivery http://localhost:8765/order-service/v1/order/6
Current code not fully adapt ACID in case update order or delivery status failure but event sent successful. To avoid this need apply OUTBOX pattern: event will save to database in table OUTBOX, use polling job (scheduler in spring boot) or debezium... send event to Kafka
Step 1: Start config service
Step 2: Start Registry service
Step 3: Start Gateway service
Step 4: Start other services
All request go through gateway:
A. External:
requests -> gateway -> services
B. Internal:
Requests -> Gateway -> Services
Requests -> Services -> Services
Open Zipkin: Running latest image docker run -d -p 9411:9411 openzipkin/zipkin. Data store in-memory
more version for zipkin: https://hub.docker.com/u/openzipkin
Admin UI: http://localhost:9411/zipkin/?serviceName=delivery-service&lookback=30m&endTs=1608301463449&limit=10
ELK
https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html
docker inspect container_id
http://{container_ip}:8766/delivery-service/actuator/prometheus
/devoops/prometheus.yml
docker run --name=prometheus -p 9090:9090 -v /Users/nguyendangtuan/Documents/Project/microservice/devoops/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
docker run -d --name=grafana -p 3000:3000 grafana/grafana user: admin/123456
- Framework and library: TestNg, Mockito, PowerMock, Spring test, Mockserver
- Unit Test
- Integration Test
- Refer setting in order-service