[go: up one dir, main page]

0% found this document useful (0 votes)
25 views9 pages

Microservices

The document outlines the process of developing microservices using Spring Boot and Netflix Eureka Server, detailing the creation of 'student-service' and 'school-service' projects. It includes steps for setting up a service registry with Eureka, configuring application properties, and running the services. Additionally, it provides instructions for registering the services with Eureka and accessing their APIs through a browser.

Uploaded by

bhanu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views9 pages

Microservices

The document outlines the process of developing microservices using Spring Boot and Netflix Eureka Server, detailing the creation of 'student-service' and 'school-service' projects. It includes steps for setting up a service registry with Eureka, configuring application properties, and running the services. Additionally, it provides instructions for registering the services with Eureka and accessing their APIs through a browser.

Uploaded by

bhanu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Date:02/Feb/2023

----------------

Microservices

-------------

- Microservices is used to break up single large monolithic system into

multiple independent components

- In Monolithic system, all functionalities are part of single program

running in a single environment

Refer diagram Monolithic Application.png

- In case of Microservices architecture, the components are built and deployed

independently to integrate into a single larger system

Refer diagram Microservices Architecture.png


Netflix Eureka Server

---------------------

Netflix Eureka Server is used for building the service registry server and

Eureka Clients which wil register themselves and discover other services

to call REST APIs

Refer diagram Eureka Server.png


Developing a Microservice Application using Spring Boot and Eureka Server

-------------------------------------------------------------------------

- Create a Spring Starter Project "student-service" in STS

Click on File -> New -> Spring Starter Project

Name : student-service

Type : Maven

Java Version : 8

Group : student-service

Artifact : student-service

Package : com.student.service

Click Next

In Project Dependencies add "Spring Web" and click Finish

- Update application.properties file of src/main/java folder to change the port number of

tomcat server

Refer program application.properties

- Create a Javabean class "Student" in com.student.service package of src/main/java folder

Refer program Student.java

- Create a Rest Controller class "StudentServiceController" in com.student.service package

Refer program StudentServiceController.java


- Run the project "student-service" as Spring Boot App

Right click on student-service -> Run As -> Spring Boot App

- Open browser and type the following APIs

- http://localhost:1111/getStudentDetailsForSchool/abcschool

- http://localhost:1111/getStudentDetailsForSchool/xyzschool
Date:03/Feb/2023

----------------

- Create a Spring Starter Project "school-service" in STS

Click on File -> New -> Spring Starter Project

Name : school-service

Type : Maven

Java Version : 8

Group : school-service

Artifact : school-service

Package : com.school.service

Click Next

In Project Dependencies add "Spring Web" and click Finish

- Update application.properties file of src/main/resources folder of school-service

Refer program application.properties

- Create a Rest Controller class "SchoolServiceController" in com.school.service package

Refer program SchoolServiceController.java

- Run the project "school-service" as Spring Boot App

- Open browser and type the following APIs

- http://localhost:2222/getSchoolDetails/abcschool
- http://localhost:2222/getSchoolDetails/xyzschool

Configure Eureka Server in STS

------------------------------

- Create a Spring Starter Project "discovery-eureka-server" in STS

Click on File -> New -> Spring Starter Project

Name : discovery-eureka-server

Type : Maven

Java Version : 8

Group : discovery-eureka-server

Artifact : discovery-eureka-server

Package : com.discovery.eureka.server

Click Next

In Project Dependencies add "Eureka Server" and click Finish

- Update pom.xml file of "discovery-eureka-server"

Refer program pom.xml

- Update "DiscoveryEurekaServerApplication.java" file of com.discovery.eureka.server

package by adding the following annotation

@EnableEurekaServer

Refer program DiscoveryEurekaServerApplication.java


- Update application.properties file of discovery-eureka-server

Refer program application.properties

- Stop all other services

- Run "discovery-eureka-server" as Spring boot app

- Open browser and type the following url

http://localhost:8761

Note: Observe the instances registed with Eureka (No instances)

Register student-service and school-service into Eureka Service Registry

------------------------------------------------------------------------

- Update pom.xml file of student-service

Refer program pom.xml

- Update application.properties file of student-service

Refer program application.properties

- Update pom.xml file of school-service

Refer program pom.xml

- Update application.properties file of school-service

Refer program application.properties


- Run student-service and school-service as Spring Boot App

- Open browser and type the following url

http://localhost:8761

Note: Observe the instances registed with Eureka

- Update "SchoolServiceController.java" file of school-service

Replace "http://localhost:1111" with "http://student-service"

Refer program SchoolServiceController.java

- Open browser and type the following APIs

- http://localhost:2222/getSchoolDetails/abcschool

- http://localhost:2222/getSchoolDetails/xyzschool

Refer programs in Microservices.zip file

You might also like