Example of a microservice architecture using Spring Cloud
MIT License
Example of a microservice architecture using Spring Cloud
The architecture is composed by four services:
discovery-service
: Service Discovery Server created with Eureka
api-gateway
: API Gateway created with Zuul that uses the discovery-service
to send the requests to the services. It uses Ribbon as Load Balancerarticle-service
: Simple REST service created with Spring Boot to use as an exampleauthor-service
: Simple REST service created with Spring Boot to use as an exampleThe services: api-gateway
, article-service
and author-service
are already configured with Hystrix (latency and fault tolerance library) and are providing a stream that you can use to monitor with a Hystrix/Turbine dashboard. You can check the Hystrix Stream accessing the service URL with /hystrix.stream
(example: http://localhost:8765/hystrix.stream
)
To test this architecture you will need to have: JDK 8+, Docker and Maven installed
Clone this repo and enter it
Run the start.sh
script, it will use Maven to build the .jar
file for each service and then use Docker to build the containers with the .jar
files
In the default configuration you will have:
8761
, access http://localhost:8761
to see the dashboard8765
, you will send the requests to this service8080
and 9080
8081
and 9081
After running the containers, head to http://localhost:8761
to make sure that the four services (two article and two author) are registered in the Discovery Service, when they're all registered you can test the application with curl
making requests to the endpoints below:
curl http://localhost:8765/api/articles
curl http://localhost:8765/api/articles/id
curl http://localhost:8765/api/articles/author/id
curl http://localhost:8765/api/authors
curl http://localhost:8765/api/authors/id
Bug reports and pull requests are welcome on GitHub at https://github.com/WendellAdriel/spring-microservices. This project is intended to be a safe, welcoming space for collaboration.
This project is available as open source under the terms of the MIT License.