AWS, Cloud Computing, Docker

4 Mins Read

Implementation of Microservices with Spring Boot on AWS and in Docker – Part 1

Voiced by Amazon Polly

Introduction

Are you still bound with the platform dependent, large monolithic applications? It is time to get over the legacy applications and to taste the fruit of microservices. You are at the right place to get started with Microservices.

The times of struggling with platform dependent, large monolithic applications have become outdated. Now are the days to start with services that helps us to deploy the same application on various platforms. Here we go with uncovering the edge of Microservices with this article.

Although monolithic application is simple to build, it has huge limitations. Application grows over time and become huge. Every week or month, the development team implements few more lines of code. As time moves, application becomes huge & complicated. It is difficult for a single developer to understand the whole application. Thus, implementing new features and removing bugs is extremely difficult and time consuming. The enormous size of the application holds back the pace of development.

Latest applications are designed in such a way that user can push changes into production multiple times in a day. It is very difficult to do the same with a complex monolithic application.

The basic idea of microservices is to breakdown an application, so that it becomes easier to build, maintain and scale.

Customized Cloud Solutions to Drive your Business Success

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

Advantages Of Working With Microservices

  • Microservices are small and focused on specific requirement
  • It can be developed by small teams
  • They are loosely coupled that means services are independent of each other in terms of development as well as deployment
  • Scaling microservices is very easy
  • Microservices allow many ways to integrate automatic deployments by using tools like Jenkins, Bamboo, etc.
  • It gives the advantage to use new cutting-edge technologies
  • High performance and flexible application

Now we shall go ahead & create a web application which is for compressing images. In this application, first you must register yourself with the application to upload the image for compressing. We will create three microservices: WebMicroservice, RegistrationMicroservice and S3Microservice.

The below diagram will help you to understand the flow of Microservices Application:

Microservices Application

Prerequisite

  • AWS Account with Access Key and Secret Key
  • Java 1.8
  • STS
  • WinSCP

Task 1: Create WebMicroservice

  1. Download the WebMicroservice present at
    http://files.cloudthat.com/microservices/WebMicroservice.zip
  2. Open STS and click on File, from the drop-down click on Import, as shown in image below:webmicroservices
  3. Click on General, from the dropdown. Select Existing Projects into Workspace and then click Next as shown below:existing webmicroservices projects
  4. Click on Select archive file, Select the downloaded archive file, and add this to STS and click on
  5. Open the application.properties file. Enter Server port for WebMicroservice. Enter RegistrationMicroservice url and S3UploadMicroservice url.

    Note:
    Port number for RegistrationMicroservice and S3UploadMicroservice must be on which you are going to run these services.
  6. In WebMicroservice, it contains only HTML templates and related class.
  7. Open DynamodbController.java and check the registerUser() method. In this method, we are sending the RegisterModel object to the RegisterMicroservice Microservice using RestTemplate’s postForObject Http Method.
  8. Right click on WebMicroservice project and run as a Spring Boot App. Type localhost:<port number> in web browser. 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

    1. Download the RegistrationMicroservice present at

    http://files.cloudthat.com/microservices/RegistrationMicroservice.zip 

  1. Import RegistrationMicroservice into STS. Follow step 2 to step 7 from Task 1.
  2. Open the application.properties Enter Access Key, Secret Key, Endpoint, Dynamodbtable name and port.

    Note: server.port
    number must be which you have given in WebMicroservice’s application.properties file’s registration.urlapplication properties
  3. Open DynamodbController.java class. You are getting the data from WebMicroservice in registeruser() method. Using @ReqestBody you will pass the data in DynamoDBModel class.Register User

Task 3: Create S3Microservice project

  1. mport S3UploadMicroservice project present at

          http://files.cloudthat.com/microservices/S3uploadMicroservice.zip

  1. Import S3UploadMicroservice into STS. Follow step 2 to step 7 from Task 1.
  2. Open the properties file. Enter Access Key, Secret Key, Endpoint, bucket name and port.

    Note: server.port
    number must be which you have given in WebMicroservice’s application.properties file’s s3.urlApplication Properties
  3. Open S3UploadMicroservice and Open S3UploadController.java. In imageUpload method you are getting the data from WebMicroservice and Implementing the logic to compress the image.
    upload webservice
  4. Right click on WebMicroservice project and run as Spring Boot App. Run RegistrationMicroservice and S3UploadMicroservice as Spring Boot App.
    spring boot app
  5. Open browser and type http://localhost:WebMicroservicePortNumaber/ then click Enter. Enter Email ID and Password for signup.
    sign up
  6. Upload any .jpg image.
    upload image
  7. Click on Download to download the compressed image.
    download image

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

Stay tuned to learn how to deploy these microservices in Docker Containers in my next blog article i.e. Implementation of Microservices with Spring Boot on AWS and in Docker – Part 2

Please feel free to post your views in the comment section below, I will be happy to discuss.

To know more about our training services, visit www.cloudthat.in and for consulting services, visit www.cloudthat.com

WRITTEN BY Bhavesh Goswami

Bhavesh Goswami is the Founder & CEO of CloudThat Technologies. He is a leading expert in the Cloud Computing space with over a decade of experience. He was in the initial development team of Amazon Simple Storage Service (S3) at Amazon Web Services (AWS) in Seattle. and has been working in the Cloud Computing and Big Data fields for over 12 years now. He is a public speaker and has been the Keynote Speaker at the ‘International Conference on Computer Communication and Informatics’. He also has authored numerous research papers and patents in various fields.

Share

Comments

  1. Kate

    May 27, 2018

    Reply

    Thanks, Megha. Nice article!
    I’m eager to read the second part of the article.

  2. MGovind

    Mar 31, 2018

    Reply

    Could you please share the link for Implementation of Microservices with Spring Boot on AWS and in Docker – Part 2

    • Jesus macias

      Jul 29, 2018

      Reply

      Could you share us the part 2 pelase ?

      • Himanshu Sachdeva

        Aug 7, 2018

        Reply

        Hello MGovind & Jesus,

        There is going to be some delay in posting part-2. We’ll update you once it is live.

        • Ashish

          Feb 28, 2020

          Reply

          Please sir, Upload part 2, It would be very helpful for us. We are waiting for part 2.

  3. Vinod

    Mar 30, 2018

    Reply

    Thanks, nice article to understand microservices

  4. Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!