SlideShare una empresa de Scribd logo
1 de 40
1
Spring Boot Micro-services
Presenter:
Prabhakaran Ravichandran
5 Day Session
2
Overall Agenda:
Day 1:
- JAVA 8 API s Introduction
- Micro-service Introduction
- Spring Boot Introduction
- Spring MVC vs Spring Boot vs Spring Reactive
- IoC & Bean configuration
- Hello World Implementation
Day 2:
- REST API s (POST/GET/PUT/PATCH)
- H2 embedded DB
- Controller Advice
- AOP Logging
- Cache Management
- Web Micro-service Implementation
Day 3:
- JUnit5
- Implementation (Cont. on Web Micro-service)
- Logging Standards & Configuration
- Scheduled Tasks
- Task Micro-service Implementation
Day 4:
- Spring Circuit Breaker
- Spring Retry
- Circuit Breaker Implementation
- Assignment
Day 5:
- Load Balancing
- Eureka Implementation
- Discussion of Problem points in Assignment
- Code Review process
3
Day 1 Agenda:
- JAVA 8 API s Introduction
- Micro-service Introduction
- Spring Boot Introduction
- Spring MVC vs Spring Boot vs Spring Reactive
- IoC & Bean configuration
- Hello World Implementation
4
Java 8 Application Programming Interfaces:
- JAR files which are imported as libraries with JAVA 8
- JDK & JRE needs to be set up to use JAVA 8
- Annotation based libraries are used
- All extended supports with JAVA 8 will be stopped 2030
- Recommended to move to JAVA 11
- JAVA 11+ versions only requires JDK
- JAVA 11 is free to use for non-commercial use cases
5
Micro-services:
- Partitioning Applications based on business context
- Faster development and deployment of newer services
- Easy prototyping and migration/integration with UI
- Favorable in migration to cloud or native cloud
infrastructure
(Horizontal Scaling, API Gateway, VPC, ALB, etc..,)
6
Monolithic:
One Application
User
Management
Leave
Management
Payroll
Management
Micro-Service:
User
Management
Leave
Management
Payroll
Management
All Different Micro-services Applications
(Integrated into an UI through REST
services)
UI
UI
7
Spring Boot:
- Auto configuration of Bean & Dependency
- Provides support for NO XML based configuration
- Reduction of boilerplate codes with Annotations
- Introduces spring-starter dependencies helps in
dependency management
- Advanced Repository interfaces which eliminates the need
for DAO implementation
- In-built server for packaging the application jar
- Only requires JAVA to deploy in an environment
- Much more powerful Annotations and their usages
8
Spring MVC vs Spring Boot:
- Spring MVC requires an WEB-INF configuration
- May create an over-head for boilerplate codes
- Difficult to manage dependencies and their version
compatibility
- Dependent on servers explicitly and requires one in every
environment where deployed
- Migration to different UI takes more time and requires full
testing of the application
Spring MVC + Advancement / Isolation = Spring Boot
9
Spring Reactive Introduction:
- Non-blocking in nature
- Event driven communication
- publisher/subscriber pattern
- Migration from Spring Boot requires architectural
& functional changes
10
Eclipse Configuration:
Environment:
- Lombok
(https://projectlombok.org/setup/eclipse)
Plugins:
- EclEmma Java Code Coverage
- Eclipse M2e - Maven Support in Eclipse IDE Latest
- EGit
- Junit-Tools
- MoreUnit
- SonarLint
- Spring Tools 4 (aka Spring Tool Suite 4)
11
Inversion Of Control & Application Context:
IoC:
- Auto Bean creation during start-up of application/Lazy load without
creating new Objects in the runtime
- During Concurrent usage of application reduces object creation overhead
load
- Auto configuring the object where ever requiring in the application using
annotation
Application Context:
- Resolving environment properties for the application
- A place where the created Beans/Component are made available
- Internalization for making application scan for component/bean in the code
12
Hello World Implementation:
Code Concepts:
- Spring Boot Starter dependencies
- Eager Loading & Lazy Loading of Beans
- Conditional Bean loading
- REST services without Response Entity
GitHub Link:
https://github.com/pbkn/HelloWorld
(To be continued in working session)
13
Day 2
Agenda:
- REST API s (POST/GET/PUT/PATCH)
- H2 embedded DB
- Controller Advice
- AOP Logging
- Cache Management
- Web Micro-service Implementation
14
Introduction to REST services:
- Makes use of HTTP verbs (POST, GET, PUT, DELETE, etc..,)
- Uses JSON as a de facto Standard for request & response
- Establishes the connection for interacting with other micro-services
through API calls
- Widely used because of its Stateless Transfer mechanism
- Supports Caching at Server
15
Hibernate:
- Maps POJO class to Database Tables
- Provides support for JPA/CRUD repository services
- Enables auto Table configuration with Annotations
- Column Validations and Sequence Generations with Annotations
16
H2 Embedded DB:
- Lightweight and in-Memory DB for prototyping new services
- Web DB console for Database management
- Supports Transaction Management
- Pure JAVA DB (imitating PostgreSQL)
- Able to support file-based DB for persisting Data
17
Controller Advice:
- Common Exception Handling for a Controller
- Reduces boilerplate codes by handling it in controller advice
class
- Handles controller and its subsequent flows exception as well
- Supports providing useful information in the response entity in
case of exceptions
- If more than one controller are present, a separate Controller
Advice is created for each
18
Point Cut:
- Part of Spring’s Aspect Oriented Programming
- Provides support for specific instructions in a common class
- Used to reduce boiler plate codes in application
- Generally used for logging purpose
19
Cache Management:
- Auto-Configuration for Concurrent Map Cache Manager
- Cache results directly on Service methods using Annotations
- Cache results, update and delete using keys
- Do not cache list of entity/entity unless recommended for business
- Highly recommended to handle cache at Server level rather than client
application level
- Default Spring Cache providers TTL (Time-To-Live) is life-cycle of the
application
20
Default Control Flow of Spring
Boot Application:
UI Controller Service Repository
DTO
Model
Mapping
Configuration
/Component
AOP
Logging
Controller
Advice
Entity
Table DDL
Bean/Table
creation on
start-up
Exception Handling/ Logging
Through out the application
21
H2 DB Implementation:
Code Concepts:
- H2 embedded in-memory DB
- Open API Swagger
- Controller Advice
- JPA Repository
- DTO Model Mapping
- Cache Management
GitHub Link:
https://github.com/pbkn/SpringDataH2
(To be continued in working session)
22
Day 3
Agenda:
- JUnit5
- Implementation (Cont. on Web Micro-service)
- Logging Standards & Configuration
- Scheduled Tasks
- Task Micro-service Implementation
23
JUnit & Log4j2:
- JUnit used for unit testing of functional requirements in code
- Optimally JUnit should cover all parts of code in business level
- Recommended to do only Standalone unit testing for the class with Mockito
- Integration / Application / Performance testing should not be written as JUnit
and carried out in actual infrastructure
- Log4j2 covers the Remote Code Execution of Log4j vulnerability which
impacted the globe
24
JUnit5 Implementation:
Code Concepts:
- MockMVC
- Mockito
- JPA Test
- App Context Loading
- Slf4j
GitHub Link:
https://github.com/pbkn/SpringDataH2
(To be continued in working session)
25
Logging Standards &
Configuration:
- Logging Standards account for the centralized logging
- PII (Personally Identifiable Information) should not be logged
- It is completely fine to use combination of centralized logging and in-line
logging
- Spring Boot log is configured by default and can be customized
- External recording of log in files / cloud / 3rd party services are always
recommended
26
Spring Boot Logging
Configuration:
2019-03-05 10:57:51.112 INFO 45469 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.52
2019-03-05 10:57:51.253 INFO 45469 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-03-05 10:57:51.253 INFO 45469 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1358 ms
2019-03-05 10:57:51.698 INFO 45469 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2019-03-05 10:57:51.702 INFO 45469 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
The following items are output:
- Date and Time: Millisecond precision
- Log Level: ERROR, WARN, INFO, DEBUG, or TRACE.
- Process ID.
- A --- separator to distinguish the start of actual log messages.
- Thread name: Enclosed in square brackets (may be truncated for console output).
- Logger name: This is usually the source class name (often abbreviated).
- The log message.
27
Scheduled Tasks:
- Scheduled Tasks run based on CRON schedule / Cloud trigger
- It is likely to be used with EVENT/QUEUE based architecture
- @Scheduled annotated method should have void return type and no
method arguments
- Exceptions are recommended to be handled at the application java file
- The application will start → do action → shutdown, whereas web micro-
service will run 24*7 listening for API call until manually shutdown
28
Task Micro-service
Implementation:
Code Concepts:
- logback file config
- .xlsx to bean
- bean to .xlsx
- scheduled CRON
GitHub Link:
https://github.com/pbkn/Logback
(To be continued in working session)
29
Day 4
Agenda:
- Spring Circuit Breaker
- Spring Retry
- Circuit Breaker Implementation
- Assignment
30
Spring Circuit Breaker:
- Circuit Breaker pattern used between micro-service to micro-service
calls/micro-service to external API call
- It will make the application fail-fast
- This pattern is best suited for enterprise applications preventing failures
in multiple points
- It has three states, OPEN, HALF-OPEN, CLOSED
- Life Cycle, CLOSED → OPEN → HALF-OPEN → CLOSED/OPEN
- It provides fallback strategy to accommodate for failure message/cache
data usage
31
Spring Circuit Breaker:
Before Circuit Breaker Pattern:
Micro A Micro B Micro C
Micro B Micro D
Failure in Micro B cascaded to Micro C & D
After Circuit Breaker Pattern:
Micro A Micro B Micro C
Micro B Micro D
Failure in Micro B failed fast and not
cascaded to Micro C & D
32
Spring Retry:
- Spring Retry is tightly coupled with Circuit Breaker Pattern
- Enables automatic retry on connection failure
- Most suitable for scheduled tasks/application with high network load
Before Retry:
Micro A Micro B Micro C
Micro B Micro D
Failure in Micro B connection to Micro C
due to network glitch
After Retry:
Micro A Micro B Micro C
Micro B Micro D
Failure in Micro B connection to Micro C
retry after connection failure
33
Circuit Breaker
Implementation:
Code Concepts:
- Spring Circuit Breaker
- Spring Retry
GitHub Link:
https://github.com/pbkn/SpringCircuitBreaker
(To be continued in working session)
34
Assignment:
Task 1:
Make a dedicated Micro-service(s) with all code concepts discussed
through out the sessions till now
Task 2:
GitHub commit your code and check for vulnerability with Snyk
35
Day 5
Agenda:
- Load Balancing
- Eureka Implementation
- Discussion of Problem points in Assignment
- Code Review process
36
Load Balancing:
- Making application available even when one instance fails
- Infra level detail to be injected via application yaml/properties
- No/Low code change is required for configuring LB
- Can be done in Server/Client Side
UI
I2
I3
I1
LB
UI
I2
I3
I1
LB
UI
I2
I3
I1
LB
UI
I2
I3
I1
LB
UI
I2
I3
I1
LB
UI
I2
I3
I1
LB
UI
I2
I3
I1
LB
UI
I2
I3
I1
LB
CLIENT SIDE
SERVER SIDE
37
Eureka Implementation:
Code Concepts:
- Eureka Server
- Eureka Client
- Eureka Ribbon Client
GitHub Link:
https://github.com/pbkn/EurekaServer
https://github.com/pbkn/EurekaClient
https://github.com/pbkn/EurekaRibbonClient
Note:
Client Side Load Balancing is not
recommended when application is
deployed in Cloud
(To be continued in working session)
38
Discussion of Problem
points in Assignment:
(Discussion Phase)
39
Code Review process:
- Use Static Code Analysis tools like SonarQube
- Use Vulnerability scanners like Snyk
- Make use of JaCoCo (Java Code Coverage) tool to check for JUnit Test
Coverage
- Get Reviewed from Peer for code readability and standards
40
KEEP LEARNING RELEVANT
THANK YOU

Más contenido relacionado

Similar a Spring_Boot_Microservices-5_Day_Session.pptx

HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...Edward Burns
 
"Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?""Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?"Volker Linz
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2divzi1913
 
Pivotal Cloud Foundry 2.6: A First Look
Pivotal Cloud Foundry 2.6: A First LookPivotal Cloud Foundry 2.6: A First Look
Pivotal Cloud Foundry 2.6: A First LookVMware Tanzu
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2Long Nguyen
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEQAware GmbH
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEMario-Leander Reimer
 
Spring Cloud Services with Pivotal Cloud Foundry- Gokhan Goksu
Spring Cloud Services with Pivotal Cloud Foundry- Gokhan GoksuSpring Cloud Services with Pivotal Cloud Foundry- Gokhan Goksu
Spring Cloud Services with Pivotal Cloud Foundry- Gokhan GoksuVMware Tanzu
 
Tuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsTuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsJean Deruelle
 
Microservices @ Work - A Practice Report of Developing Microservices
Microservices @ Work - A Practice Report of Developing MicroservicesMicroservices @ Work - A Practice Report of Developing Microservices
Microservices @ Work - A Practice Report of Developing MicroservicesQAware GmbH
 
Best practices for large oracle apps r12 implementations apps14
Best practices for large oracle apps r12 implementations apps14Best practices for large oracle apps r12 implementations apps14
Best practices for large oracle apps r12 implementations apps14Ajith Narayanan
 
Functioning incessantly of Data Science Platform with Kubeflow - Albert Lewan...
Functioning incessantly of Data Science Platform with Kubeflow - Albert Lewan...Functioning incessantly of Data Science Platform with Kubeflow - Albert Lewan...
Functioning incessantly of Data Science Platform with Kubeflow - Albert Lewan...GetInData
 
Google appenginejava.ppt
Google appenginejava.pptGoogle appenginejava.ppt
Google appenginejava.pptYoung Alista
 
Sap Process Integration
Sap Process Integration Sap Process Integration
Sap Process Integration Tauhidul Islam
 
UI5con 2017 - UI5 Components - More Performance...
UI5con 2017 - UI5 Components - More Performance...UI5con 2017 - UI5 Components - More Performance...
UI5con 2017 - UI5 Components - More Performance...Peter Muessig
 
WebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination FeaturesWebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination FeaturesChris Bailey
 
Hia 1691-using iib-to_support_api_economy
Hia 1691-using iib-to_support_api_economyHia 1691-using iib-to_support_api_economy
Hia 1691-using iib-to_support_api_economyAndrew Coleman
 
Synopsis on online shopping by sudeep singh
Synopsis on online shopping by  sudeep singhSynopsis on online shopping by  sudeep singh
Synopsis on online shopping by sudeep singhSudeep Singh
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overviewskill-guru
 

Similar a Spring_Boot_Microservices-5_Day_Session.pptx (20)

HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
 
"Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?""Wie passen Serverless & Autonomous zusammen?"
"Wie passen Serverless & Autonomous zusammen?"
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
Pivotal Cloud Foundry 2.6: A First Look
Pivotal Cloud Foundry 2.6: A First LookPivotal Cloud Foundry 2.6: A First Look
Pivotal Cloud Foundry 2.6: A First Look
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EE
 
A Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EEA Hitchhiker's Guide to Cloud Native Java EE
A Hitchhiker's Guide to Cloud Native Java EE
 
Spring Cloud Services with Pivotal Cloud Foundry- Gokhan Goksu
Spring Cloud Services with Pivotal Cloud Foundry- Gokhan GoksuSpring Cloud Services with Pivotal Cloud Foundry- Gokhan Goksu
Spring Cloud Services with Pivotal Cloud Foundry- Gokhan Goksu
 
Tuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on MobicentsTuning and development with SIP Servlets on Mobicents
Tuning and development with SIP Servlets on Mobicents
 
Microservices @ Work - A Practice Report of Developing Microservices
Microservices @ Work - A Practice Report of Developing MicroservicesMicroservices @ Work - A Practice Report of Developing Microservices
Microservices @ Work - A Practice Report of Developing Microservices
 
Best practices for large oracle apps r12 implementations apps14
Best practices for large oracle apps r12 implementations apps14Best practices for large oracle apps r12 implementations apps14
Best practices for large oracle apps r12 implementations apps14
 
Functioning incessantly of Data Science Platform with Kubeflow - Albert Lewan...
Functioning incessantly of Data Science Platform with Kubeflow - Albert Lewan...Functioning incessantly of Data Science Platform with Kubeflow - Albert Lewan...
Functioning incessantly of Data Science Platform with Kubeflow - Albert Lewan...
 
Ready! Steady! SpringBoot!
Ready! Steady! SpringBoot! Ready! Steady! SpringBoot!
Ready! Steady! SpringBoot!
 
Google appenginejava.ppt
Google appenginejava.pptGoogle appenginejava.ppt
Google appenginejava.ppt
 
Sap Process Integration
Sap Process Integration Sap Process Integration
Sap Process Integration
 
UI5con 2017 - UI5 Components - More Performance...
UI5con 2017 - UI5 Components - More Performance...UI5con 2017 - UI5 Components - More Performance...
UI5con 2017 - UI5 Components - More Performance...
 
WebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination FeaturesWebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination Features
 
Hia 1691-using iib-to_support_api_economy
Hia 1691-using iib-to_support_api_economyHia 1691-using iib-to_support_api_economy
Hia 1691-using iib-to_support_api_economy
 
Synopsis on online shopping by sudeep singh
Synopsis on online shopping by  sudeep singhSynopsis on online shopping by  sudeep singh
Synopsis on online shopping by sudeep singh
 
Struts 2 Overview
Struts 2 OverviewStruts 2 Overview
Struts 2 Overview
 

Más de Prabhakaran Ravichandran (13)

How to create GIF files without any restrictions
How to create GIF files without any restrictionsHow to create GIF files without any restrictions
How to create GIF files without any restrictions
 
Fun Quiz for any events
Fun Quiz for any eventsFun Quiz for any events
Fun Quiz for any events
 
Problem solving
Problem solvingProblem solving
Problem solving
 
Positive intention
Positive intentionPositive intention
Positive intention
 
Decision making
Decision makingDecision making
Decision making
 
Creativity
CreativityCreativity
Creativity
 
Electrostatic harmful effects & control measures
Electrostatic harmful effects & control measuresElectrostatic harmful effects & control measures
Electrostatic harmful effects & control measures
 
Power transmission & distribution
Power transmission & distributionPower transmission & distribution
Power transmission & distribution
 
properties and phenomenon in crystals
properties and phenomenon in crystalsproperties and phenomenon in crystals
properties and phenomenon in crystals
 
Logic gates
Logic gatesLogic gates
Logic gates
 
Polymers
PolymersPolymers
Polymers
 
LED'S
LED'SLED'S
LED'S
 
Modern engg. materials
Modern engg. materialsModern engg. materials
Modern engg. materials
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 

Último (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Spring_Boot_Microservices-5_Day_Session.pptx

  • 2. 2 Overall Agenda: Day 1: - JAVA 8 API s Introduction - Micro-service Introduction - Spring Boot Introduction - Spring MVC vs Spring Boot vs Spring Reactive - IoC & Bean configuration - Hello World Implementation Day 2: - REST API s (POST/GET/PUT/PATCH) - H2 embedded DB - Controller Advice - AOP Logging - Cache Management - Web Micro-service Implementation Day 3: - JUnit5 - Implementation (Cont. on Web Micro-service) - Logging Standards & Configuration - Scheduled Tasks - Task Micro-service Implementation Day 4: - Spring Circuit Breaker - Spring Retry - Circuit Breaker Implementation - Assignment Day 5: - Load Balancing - Eureka Implementation - Discussion of Problem points in Assignment - Code Review process
  • 3. 3 Day 1 Agenda: - JAVA 8 API s Introduction - Micro-service Introduction - Spring Boot Introduction - Spring MVC vs Spring Boot vs Spring Reactive - IoC & Bean configuration - Hello World Implementation
  • 4. 4 Java 8 Application Programming Interfaces: - JAR files which are imported as libraries with JAVA 8 - JDK & JRE needs to be set up to use JAVA 8 - Annotation based libraries are used - All extended supports with JAVA 8 will be stopped 2030 - Recommended to move to JAVA 11 - JAVA 11+ versions only requires JDK - JAVA 11 is free to use for non-commercial use cases
  • 5. 5 Micro-services: - Partitioning Applications based on business context - Faster development and deployment of newer services - Easy prototyping and migration/integration with UI - Favorable in migration to cloud or native cloud infrastructure (Horizontal Scaling, API Gateway, VPC, ALB, etc..,)
  • 7. 7 Spring Boot: - Auto configuration of Bean & Dependency - Provides support for NO XML based configuration - Reduction of boilerplate codes with Annotations - Introduces spring-starter dependencies helps in dependency management - Advanced Repository interfaces which eliminates the need for DAO implementation - In-built server for packaging the application jar - Only requires JAVA to deploy in an environment - Much more powerful Annotations and their usages
  • 8. 8 Spring MVC vs Spring Boot: - Spring MVC requires an WEB-INF configuration - May create an over-head for boilerplate codes - Difficult to manage dependencies and their version compatibility - Dependent on servers explicitly and requires one in every environment where deployed - Migration to different UI takes more time and requires full testing of the application Spring MVC + Advancement / Isolation = Spring Boot
  • 9. 9 Spring Reactive Introduction: - Non-blocking in nature - Event driven communication - publisher/subscriber pattern - Migration from Spring Boot requires architectural & functional changes
  • 10. 10 Eclipse Configuration: Environment: - Lombok (https://projectlombok.org/setup/eclipse) Plugins: - EclEmma Java Code Coverage - Eclipse M2e - Maven Support in Eclipse IDE Latest - EGit - Junit-Tools - MoreUnit - SonarLint - Spring Tools 4 (aka Spring Tool Suite 4)
  • 11. 11 Inversion Of Control & Application Context: IoC: - Auto Bean creation during start-up of application/Lazy load without creating new Objects in the runtime - During Concurrent usage of application reduces object creation overhead load - Auto configuring the object where ever requiring in the application using annotation Application Context: - Resolving environment properties for the application - A place where the created Beans/Component are made available - Internalization for making application scan for component/bean in the code
  • 12. 12 Hello World Implementation: Code Concepts: - Spring Boot Starter dependencies - Eager Loading & Lazy Loading of Beans - Conditional Bean loading - REST services without Response Entity GitHub Link: https://github.com/pbkn/HelloWorld (To be continued in working session)
  • 13. 13 Day 2 Agenda: - REST API s (POST/GET/PUT/PATCH) - H2 embedded DB - Controller Advice - AOP Logging - Cache Management - Web Micro-service Implementation
  • 14. 14 Introduction to REST services: - Makes use of HTTP verbs (POST, GET, PUT, DELETE, etc..,) - Uses JSON as a de facto Standard for request & response - Establishes the connection for interacting with other micro-services through API calls - Widely used because of its Stateless Transfer mechanism - Supports Caching at Server
  • 15. 15 Hibernate: - Maps POJO class to Database Tables - Provides support for JPA/CRUD repository services - Enables auto Table configuration with Annotations - Column Validations and Sequence Generations with Annotations
  • 16. 16 H2 Embedded DB: - Lightweight and in-Memory DB for prototyping new services - Web DB console for Database management - Supports Transaction Management - Pure JAVA DB (imitating PostgreSQL) - Able to support file-based DB for persisting Data
  • 17. 17 Controller Advice: - Common Exception Handling for a Controller - Reduces boilerplate codes by handling it in controller advice class - Handles controller and its subsequent flows exception as well - Supports providing useful information in the response entity in case of exceptions - If more than one controller are present, a separate Controller Advice is created for each
  • 18. 18 Point Cut: - Part of Spring’s Aspect Oriented Programming - Provides support for specific instructions in a common class - Used to reduce boiler plate codes in application - Generally used for logging purpose
  • 19. 19 Cache Management: - Auto-Configuration for Concurrent Map Cache Manager - Cache results directly on Service methods using Annotations - Cache results, update and delete using keys - Do not cache list of entity/entity unless recommended for business - Highly recommended to handle cache at Server level rather than client application level - Default Spring Cache providers TTL (Time-To-Live) is life-cycle of the application
  • 20. 20 Default Control Flow of Spring Boot Application: UI Controller Service Repository DTO Model Mapping Configuration /Component AOP Logging Controller Advice Entity Table DDL Bean/Table creation on start-up Exception Handling/ Logging Through out the application
  • 21. 21 H2 DB Implementation: Code Concepts: - H2 embedded in-memory DB - Open API Swagger - Controller Advice - JPA Repository - DTO Model Mapping - Cache Management GitHub Link: https://github.com/pbkn/SpringDataH2 (To be continued in working session)
  • 22. 22 Day 3 Agenda: - JUnit5 - Implementation (Cont. on Web Micro-service) - Logging Standards & Configuration - Scheduled Tasks - Task Micro-service Implementation
  • 23. 23 JUnit & Log4j2: - JUnit used for unit testing of functional requirements in code - Optimally JUnit should cover all parts of code in business level - Recommended to do only Standalone unit testing for the class with Mockito - Integration / Application / Performance testing should not be written as JUnit and carried out in actual infrastructure - Log4j2 covers the Remote Code Execution of Log4j vulnerability which impacted the globe
  • 24. 24 JUnit5 Implementation: Code Concepts: - MockMVC - Mockito - JPA Test - App Context Loading - Slf4j GitHub Link: https://github.com/pbkn/SpringDataH2 (To be continued in working session)
  • 25. 25 Logging Standards & Configuration: - Logging Standards account for the centralized logging - PII (Personally Identifiable Information) should not be logged - It is completely fine to use combination of centralized logging and in-line logging - Spring Boot log is configured by default and can be customized - External recording of log in files / cloud / 3rd party services are always recommended
  • 26. 26 Spring Boot Logging Configuration: 2019-03-05 10:57:51.112 INFO 45469 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.52 2019-03-05 10:57:51.253 INFO 45469 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2019-03-05 10:57:51.253 INFO 45469 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1358 ms 2019-03-05 10:57:51.698 INFO 45469 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2019-03-05 10:57:51.702 INFO 45469 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] The following items are output: - Date and Time: Millisecond precision - Log Level: ERROR, WARN, INFO, DEBUG, or TRACE. - Process ID. - A --- separator to distinguish the start of actual log messages. - Thread name: Enclosed in square brackets (may be truncated for console output). - Logger name: This is usually the source class name (often abbreviated). - The log message.
  • 27. 27 Scheduled Tasks: - Scheduled Tasks run based on CRON schedule / Cloud trigger - It is likely to be used with EVENT/QUEUE based architecture - @Scheduled annotated method should have void return type and no method arguments - Exceptions are recommended to be handled at the application java file - The application will start → do action → shutdown, whereas web micro- service will run 24*7 listening for API call until manually shutdown
  • 28. 28 Task Micro-service Implementation: Code Concepts: - logback file config - .xlsx to bean - bean to .xlsx - scheduled CRON GitHub Link: https://github.com/pbkn/Logback (To be continued in working session)
  • 29. 29 Day 4 Agenda: - Spring Circuit Breaker - Spring Retry - Circuit Breaker Implementation - Assignment
  • 30. 30 Spring Circuit Breaker: - Circuit Breaker pattern used between micro-service to micro-service calls/micro-service to external API call - It will make the application fail-fast - This pattern is best suited for enterprise applications preventing failures in multiple points - It has three states, OPEN, HALF-OPEN, CLOSED - Life Cycle, CLOSED → OPEN → HALF-OPEN → CLOSED/OPEN - It provides fallback strategy to accommodate for failure message/cache data usage
  • 31. 31 Spring Circuit Breaker: Before Circuit Breaker Pattern: Micro A Micro B Micro C Micro B Micro D Failure in Micro B cascaded to Micro C & D After Circuit Breaker Pattern: Micro A Micro B Micro C Micro B Micro D Failure in Micro B failed fast and not cascaded to Micro C & D
  • 32. 32 Spring Retry: - Spring Retry is tightly coupled with Circuit Breaker Pattern - Enables automatic retry on connection failure - Most suitable for scheduled tasks/application with high network load Before Retry: Micro A Micro B Micro C Micro B Micro D Failure in Micro B connection to Micro C due to network glitch After Retry: Micro A Micro B Micro C Micro B Micro D Failure in Micro B connection to Micro C retry after connection failure
  • 33. 33 Circuit Breaker Implementation: Code Concepts: - Spring Circuit Breaker - Spring Retry GitHub Link: https://github.com/pbkn/SpringCircuitBreaker (To be continued in working session)
  • 34. 34 Assignment: Task 1: Make a dedicated Micro-service(s) with all code concepts discussed through out the sessions till now Task 2: GitHub commit your code and check for vulnerability with Snyk
  • 35. 35 Day 5 Agenda: - Load Balancing - Eureka Implementation - Discussion of Problem points in Assignment - Code Review process
  • 36. 36 Load Balancing: - Making application available even when one instance fails - Infra level detail to be injected via application yaml/properties - No/Low code change is required for configuring LB - Can be done in Server/Client Side UI I2 I3 I1 LB UI I2 I3 I1 LB UI I2 I3 I1 LB UI I2 I3 I1 LB UI I2 I3 I1 LB UI I2 I3 I1 LB UI I2 I3 I1 LB UI I2 I3 I1 LB CLIENT SIDE SERVER SIDE
  • 37. 37 Eureka Implementation: Code Concepts: - Eureka Server - Eureka Client - Eureka Ribbon Client GitHub Link: https://github.com/pbkn/EurekaServer https://github.com/pbkn/EurekaClient https://github.com/pbkn/EurekaRibbonClient Note: Client Side Load Balancing is not recommended when application is deployed in Cloud (To be continued in working session)
  • 38. 38 Discussion of Problem points in Assignment: (Discussion Phase)
  • 39. 39 Code Review process: - Use Static Code Analysis tools like SonarQube - Use Vulnerability scanners like Snyk - Make use of JaCoCo (Java Code Coverage) tool to check for JUnit Test Coverage - Get Reviewed from Peer for code readability and standards