Simple system mixing the two main ways for communication between microservices: REST and messaging.
- Service registry (Eureka) — Where all services will register themselves
- Config server (Spring Cloud Config) — Where all services will take their configurations from. Config server will keep configuration files in git repository
- Gateway (Zuul) — that will redirect all the requests to the needed microservice
- User service — using this one the new users will register. On every new registration the User service will send a message “USER_REGISTERED” to the message broker (Kafka)
- Email service — using this one we will send emails. On “USER_REGISTERED”message received the Email service will send a confirmation email to the new user
The asynchronous communication is performed through Apache Kafka, therefore first it must be started
Kafka uses ZooKeeper so you need to first start a ZooKeeper server if you don't already have one.
> bin/zookeeper-server-start.sh config/zookeeper.properties
Now start the Kafka server:
> bin/kafka-server-start.sh config/server.properties
- Start the Service registry (ms-discovery)
- Start the Config server (ms-config-server)
- Start the Gateway (ms-gateway)
- Start the User service (ms-user)
- Start the Mail service (ms-mail)
- Register a new user
curl -X POST \
http://localhost:8765/api/user \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"username": "[email protected]",
"password": "mynewpass"
}'
- Validate that the new user has been registered on User service
- Validate that a new mail has been received on [email protected] account