Skip to content

aiellomau/improve-microservice-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Microservice Sample - Island Reservations

The goal of this sample project is to describe how to use spring in a microservices environment.

It uses three microservices:

  • Reservation to process reservations on a campsite.
  • User to handle user data.
  • Campsite to handle campsite data. (By the default there is only one campsite for reservation)

Technologies

  • Eureka for Lookup.
  • Hystrix is used for resilience.
  • Zuul is used to route HTTP requests from the outside to different services.
  • Spring Cloud Config.
  • Spring Boot Admin. Use as a dashboard of all microservices.
  • Feign - For Rest services connections withing microservices. Avoid Rest API implementation staff.
  • RabbitMQ - For exchanges messages between microservices.

Assumptions:

Although we only have one place to camp on the island, I assumed that this could change in the future. Bearing in mind that in the near future you will probably have more than one campsite. Therefore, the solution will be more flexible to avoid future changes. Also, I assume that a user can reserve even though has already done it before. So a user can have more than one reservation.

Technical Staff:

At the moment I use hsqldb as datastore. In the future, I will move to a NoSQL or a Relational one. I have not decided yet. This depends on each microservice requirement.

How To Run

Each Microservice has its own script names standalone.sh. It is recommended to have several terminals to run all.

# Start Discovery
$ cd eureka-server
$ sh standalone.sh
# Config Server
$ cd config-server
$ sh standalone.sh
# Dashboard
$ cd dashboard-server
$ sh standalone.sh
# Api Gateway
$ cd zuul-server
$ sh standalone.sh
# Start User Microservice
$ cd user-ms
$ sh standalone.sh
# Start Campsite Microservice
$ cd campsite-ms
$ sh standalone.sh
# Start Reservation Microservice
$ cd registration-ms
$ sh standalone.sh

Then, if all is ok, try to ping Eureka server -> http://localhost:8761/

Read more on: https://github.com/aiellomau/improve-microservice-sample/tree/master/microservices

Microservices Projects

The servers for the infrastructure are pretty simple thanks to Spring Cloud:

  • eureka-server: is the Eureka server for service discovery.
  • config-server: is the Config server. It holds all properties values for each ms. All properties are hosting on GitHub: https://github.com/aiellomau/improve-microservice-configserver
  • dashboard-server: Monitor all microservices instances.
  • zuul-server: is the Zuul server. Distributes the requests to the three microservices.

The microservices are:

  • campsite: is the application to take care of items.
  • user: is responsible for customers.
  • reservation: does reservation processing. It uses campsite and user microservices.

RabbitMQ instance (Just for testing communication between microservices)

docker pull rabbitmq:3-management
docker run -d --hostname my-rabbit --name some-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management

Microservices

Future enhancements

Add Docker-Swarn / Kubernetes.