Technology Used

Why do we need service registry?

A microservice ecosystem may consist of a high number of services that need to know each other’s location. If we have multiple environments (dev, qa, uat, prod) then configuring all these services can be very time consuming and error prone.

in a cloud environment the ip address and port of the services are not known in advance. Based on demand new service instances can be added or removed on the fly.

The solution is to create the “telephone book” of services, called service registry. Spring cloud is integrated with Eureka from Netflix OSS, Consul and Zookeeper

Starting up an Eureka server

Eureka was created and opensourced by Netflix. Spring created a nice wrapper around it, so it can be started up as a spring boot application. It is as easy as downloading an empty spring boot skeleton and adding the following dependency

REST interfaces can be very effectively used “natively” from javascript and node js, but languages with compile time time type check, require a client library. Java developers spend a lot of time writing write boilerplate code for REST clients. Feign offers a solution to dynamically generate clients from the interface. Additional benefit is that we can keep the signature of the service and client identical. First we need to declare an interface with all the Spring request mapping annotations :