Part 1: Implementation of Microservices using Spring Boot in AWS and Docker
Are you still tied to platform-dependent, large monolithic apps? It’s time to let go of legacy applications and enjoy the fruits of microservices. Microservices are easy to start.
It is no longer necessary to struggle with large, monolithic, platform-dependent applications. These days, we can start to use services that allow us to deploy the same application across multiple platforms. This article will help you discover the best Microservices.
Monolithic applications are simple to create, but they have many limitations. The application grows over time and becomes huge. Each week, or month, the development team implements a few more lines code. Application becomes more complex and large as time passes. It is very difficult for one developer to understand the entire application. It is therefore difficult and time-consuming to implement new features or fix bugs. The application’s large size slows down the development pace.
Modern applications can be modified multiple times per day by the user. It is difficult to do the exact same thing with a monolithic, complex application.
Microservices are designed to simplify an application so it is easier to build, maintain, and scale.
Here are some of the benefits of microservices:
Microservices are focused on a specific need and are very small.
It can be developed by small groups
They are loosely connected, which means that services can be developed and deployed independently of each other.
Scaling microservices can be done easily
Microservices can be used to integrate automated deployments using tools like Bamboo, Jenkins, and others.
This gives you the opportunity to use cutting-edge technologies
Flexible and high performance
We will now create a web app for compressing images. To upload an image for compression, you will first need to register with the application. We will create three microservices: WebMicroservice, RegistrationMicroservice and S3Microservice.
This diagram will help you understand the flow of Microservices Application.
AWS Account with Access Key & Secret Key
Task 1: Create a WebMicroservice
Download the WebMicroservice present athttp://files.cloudthat.com/microservices/WebMicroservice.zip
Open STS, click on File, and from the drop-down, click on Import as shown in the image below.
From the dropdown, click on General. Select Existing Projects and click Next, as shown below.
Click on Select archive file. Select the archive file you downloaded and then add it to STS.
Open the application.properties file. Enter the WebMicroservice port. Enter RegistrationMicroservice url and S3UploadMicroservice url.Note: Port number for RegistrationMicroservice and S3UploadMicroservice must be on which you are going to run these services.
WebMicroservice only contains HTML templates and related classes.
Open DynamodbController.java and check the registerUser() method. This method sends the RegisterModel object to RegisterMicroservice Microservice via RestTemplate’s postForObject HTTP Method.
Right click on WebMicroservice and run as Spring Boot App. In your web browser, type localhost: Again, you can see registration page.When you enter all details and click on sign up button you will see the connection refused error because RegistrationMicroservice is not running.
Task 2: Create RegistrationMicroservice
Download the RegistrationMicroservice present at
Import RegistrationMicroservice into STS. Follow Step 2 to Step 7 from Task 1.
Open the application.properties Enter Access Key, Secret Key, Endpoint, Dynamodbtable name