Your very first Microservice

In the domain of a smart city, there are many sensors measuring local climate conditions, such as temperature or humidity. Let's assume that the temperature data is used by some other systems in the city. How do these other systems obtain information about the current temperature? A dedicated service that does one thing well is a Weather Microservice. Writing the code over and over again with each new system results in low code reuse, high additional costs, and difficult maintainability. Thus, the entire logic of dealing with weather data is extracted into one Microservice that other systems may call at any time. In order for the other systems to be able to communicate with our Weather Microservice, a means of communication must be set up. Therefore, the Weather Microservice has a strictly defined application interface. In the age of the internet and Web 2.0, where HTTP as a protocol is well established and accepted, choosing a RESTful interface ensures barrier-free access to the Microservice.

The goal is therefore to create a simple Weather Microservice that provides data about the temperature in the city. The service is going to communicate with the outer world by means of a RESTful interface over an HTTP protocol.

The process of creation of this Microservice will be demonstrated with both Java EE and Spring Boot. The source code of the Microservices created in this chapter are available on GitHub. The repository contains a finished project with thoroughly commented code, ready to be run.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.28.179