SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Developing
Microservices
using Spring
-
Beginners Guide
* Disclaimer: There are various topics covered in this session, each topic is worth a 2 day workshop session in itself, so this will cover only the very basics and try
to provide a birds eye view of the various concepts.
Agenda
● Microservices
● What ?
● Why ?
● Challenges of a distributed system
● Building Microservices using Spring
● Spring Boot
● Spring Cloud & Netflix OSS
● Conclusion
All Roads Lead to Microservices
Cloud
aPaaS
Continuous Delivery
Dev Ops
Agile
Microservices
Microservices – What ?
The term "Microservice Architecture" has sprung up over the
last few years to describe a particular way of designing
software applications as suites of independently deployable
services.
-Martin Fowler
http://martinfowler.com/articles/microservices.html
Microservices are loosely coupled service oriented
architecture with bounded contexts.
- Adrian Cockroft
Monolith Application
● Imaginary E-Commerce App
● Very efficient inter process calls between
components
● Good architecture, until it needs to scale
during busy shopping season.
Monolith Application
● You want to scale only 'Shopping
Cart' and 'Checkout' Modules,
but instead have to scale the
entire App
● Other Challenges with multiple
database and Session
management
Monolith Application – Good Parts
● Contains Everything
● Single Deployment
● Minimum viable product can
be reached quickly
● Easy (or Familiar) to understand
Monolith Application – Bad Parts
● Complex Architecture
● Difficult to Scale
(cannot scale only selected
modules)
● Long term commitment
to one technical stack
Microservices
● Distillation of SOA
● Single Context
● Smart Services / Dumb Pipes
● RESTful Communications
● Smaller codebase – easy to
reason about
● Easy to scale
Microservices
Challenges of distributed system
● Configuration Management
● Service Registration & Discovery
● Load Balancing
● Fault Tolerance
● Monitoring
● Concurrent API Integration & Transformation
*(This is not a complete list...)
Spring Boot
● Built on top of Spring framework
● Opinionated convention over configuration
● Creates stand-alone “Production” ready app
● Embedded Tomcat / Jetty
● Various Starters POMs to simplify configuration
● https://start.spring.io/ - Spring Initializr template project (We can
replace our kick start scripts with something like this)
Spring Boot
● It can get pretty small..
@RestController
class ThisWillActuallyRun {
@RequestMapping("/")
String home() {
"Hello World!"
}
}
Exercise 1 : Spring Boot Hello World
Spring Boot
● Retrieve data from database – Spring Data REST
● Entity Class
@Entity
@Table(name="users")
public class User implements Serializable{... }
● Repository Class
@Repository
public interface UserRepository extends JpaRepository<User, Integer> { }
● Main Class
@SpringBootApplication
public class SampleDataJpaApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleDataJpaApplication.class, args);
}
}
● The same project runs in local and Cloud - PWS
Exercise 2 : Spring Data REST
Spring Cloud
● Writing a single service with Spring Boot is easy.
● But things gets complex with managing multiple services
● http://cloud.spring.io/spring-cloud-netflix/ , to the rescue.
● Similar to Spring Data umbrella project.
Spring Cloud Netflix
● Configuration Management – Spring Cloud Config
● Service Registration & Discovery – Eureka
● Load Balancing – Feign & Ribbon
● Fault Tolerance (Circuit Breaker) – Hysterix
● Monitoring – Hysterix Dashboard
● Concurrent API Integration & Transformation - RxJava
Spring Cloud Config
● Distributed configuration management.
● Provides server and client-side support for externalized configuration.
● Store Configuration properties (YAML content) in remote repository (Git
supported by default)
● Curl -X POST http://localhost:8888/bus/refresh, to get the latest values from
the config server.
Exercise 3 : Config Server
Cloud Bus (AMQP / RabbitMQ)
Git (default)
properties
Config Server
/refresh
/refresh
Service Registry & Discovery - Eureka
● Eureka is Netflix OSS Project for Service Discovery Server & Client.
● Eureka Server – can be configured to be highly available, supports server
replication for resiliency.
● Clients registers with Eureka and sends heartbeat messages to Server.
● Eureka Server
@EnableEurekaServer
class Eureka {
}
● Eureka Client
@EnableDiscoveryClient
public class Application {... }
● Producer Consumer example
Exercise 4 : Eureka – Producer / Consumer
Load balancing - Ribbon
● Ribbon is a Netflix OSS Project, it provides software load balancers with
cluster of servers.
● Provides basic functionality like supply the public DNS name of servers
to client, rotate among the list of servers according to certain logic.
● Load balancer components
Rule – logic to determine which server to return from the serverlist.
Ping – to ensure server liveness
ServerList – can be static or dynamic
● Spring RestTemplate has been added with little bit of magic and made
Ribbon enabled.
● FeignClient is alternative to Spring RestTemplate, Feign is declarative
web service client, makes writing web service clients easier.
Exercise 5 : Producer / Consumer example with load balancer / Feign
Fault Tolerance - Hystrix
● Hystrix – Circuit Breaker Pattern
● Its a state machine, with 3 states – Closed, Open and Half-Open.
● Failures does not cascade up to the top of the call stack.
Exercise 6 : Hystrix in action
Monitoring
● Hystrix Dashboard
Import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard
@EnableHystrixDashboard
class HystrixDashboard { … }
Exercise 7 : Hystrix Dashboard in action
Concurrent API Integration - RxJava
● RxJava is Java implementation of MS
Reactive Extensions.
● A library for composing asynchronous
and event-based programs by using
Observable sequences.
● Netflix created RxJava to simplify
server side concurrency, a single
“heavy” client request that is executed
in parallel on the server.
● The service layer API method return an Observable<T> getData(), this can be
asynch or synch, and its transparent to the caller of this service.
● Can be achieved using Java Futures, but it supports one value, not for a
sequences. Also calling Future.get() will be a blocking.
● Callbacks can be used for asynchronous execution and works well for single level
of execution, but things gets complicated with nested Callbacks (callback hell !).
Conclusion
● Microservices Architectural Style needs certain infrastructure competencies
like, Rapid Provisioning, Continuous Delivery, Basic Monitoring, etc.,
● There are many new design patterns to learn when implementing a
distributed system.
● Spring Cloud Netflix implements certain patterns and Spring Boot makes it
easy to use.
References
● http://martinfowler.com/articles/microservices.html
● http://martinfowler.com/bliki/MicroservicePrerequisites.html
● http://projects.spring.io/spring-boot/
● http://projects.spring.io/spring-cloud/
● http://cloud.spring.io/spring-cloud-netflix/
● http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html
● https://github.com/ReactiveX/RxJava
● http://www.infoq.com/presentations/reactive-arch-grails
● http://www.infoq.com/presentations/Netflix-API-rxjava-hystrix
Images
● https://www.flickr.com/photos/bhophoto/384574407/

Weitere ähnliche Inhalte

Was ist angesagt?

Building ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloudBuilding ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloudIdan Fridman
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminarGal Marder
 
Spring Boot
Spring BootSpring Boot
Spring Bootgedoplan
 
Asynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAsynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAlex Thissen
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudEberhard Wolff
 
Validating latest changes with XCI
Validating latest changes with XCIValidating latest changes with XCI
Validating latest changes with XCIVictor Morales
 
Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019J V
 
Gradual migration to MicroProfile
Gradual migration to MicroProfileGradual migration to MicroProfile
Gradual migration to MicroProfileRudy De Busscher
 
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014Amazon Web Services
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014scolestock
 
Advanced Spring Boot with Consul
Advanced Spring Boot with ConsulAdvanced Spring Boot with Consul
Advanced Spring Boot with ConsulVMware Tanzu
 
Spring Web flow. A little flow of happiness
Spring Web flow. A little flow of happinessSpring Web flow. A little flow of happiness
Spring Web flow. A little flow of happinessStrannik_2013
 
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»DataArt
 
How to contribute to an open source project and don’t die during the Code Rev...
How to contribute to an open source project and don’t die during the Code Rev...How to contribute to an open source project and don’t die during the Code Rev...
How to contribute to an open source project and don’t die during the Code Rev...Victor Morales
 
Moving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesMoving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesJeff Potts
 
KKBOX WWDC17 Security - Antony
KKBOX WWDC17 Security - AntonyKKBOX WWDC17 Security - Antony
KKBOX WWDC17 Security - AntonyLiyao Chen
 
ASP.NET Core Demos
ASP.NET Core DemosASP.NET Core Demos
ASP.NET Core DemosErik Noren
 

Was ist angesagt? (20)

Building ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloudBuilding ‘Bootiful’ microservices cloud
Building ‘Bootiful’ microservices cloud
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminar
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Asynchronous programming in ASP.NET
Asynchronous programming in ASP.NETAsynchronous programming in ASP.NET
Asynchronous programming in ASP.NET
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
 
Validating latest changes with XCI
Validating latest changes with XCIValidating latest changes with XCI
Validating latest changes with XCI
 
Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019Alfresco Transform Service DevCon 2019
Alfresco Transform Service DevCon 2019
 
Gradual migration to MicroProfile
Gradual migration to MicroProfileGradual migration to MicroProfile
Gradual migration to MicroProfile
 
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
(APP309) Running and Monitoring Docker Containers at Scale | AWS re:Invent 2014
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014
 
Advanced Spring Boot with Consul
Advanced Spring Boot with ConsulAdvanced Spring Boot with Consul
Advanced Spring Boot with Consul
 
Spring Web flow. A little flow of happiness
Spring Web flow. A little flow of happinessSpring Web flow. A little flow of happiness
Spring Web flow. A little flow of happiness
 
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
 
How to contribute to an open source project and don’t die during the Code Rev...
How to contribute to an open source project and don’t die during the Code Rev...How to contribute to an open source project and don’t die during the Code Rev...
How to contribute to an open source project and don’t die during the Code Rev...
 
ASP.NET vNext
ASP.NET vNextASP.NET vNext
ASP.NET vNext
 
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin KalapaćJavantura v4 - FreeMarker in Spring web - Marin Kalapać
Javantura v4 - FreeMarker in Spring web - Marin Kalapać
 
Moving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to MicroservicesMoving From Actions & Behaviors to Microservices
Moving From Actions & Behaviors to Microservices
 
KKBOX WWDC17 Security - Antony
KKBOX WWDC17 Security - AntonyKKBOX WWDC17 Security - Antony
KKBOX WWDC17 Security - Antony
 
ASP.NET Core Demos
ASP.NET Core DemosASP.NET Core Demos
ASP.NET Core Demos
 
Containerize!
Containerize!Containerize!
Containerize!
 

Ähnlich wie Developing Microservices using Spring - Beginner's Guide

Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with javaDPC Consulting Ltd
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kuberneteskloia
 
Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice frameworkFabrice Sznajderman
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAndrei Sebastian Cîmpean
 
Introduction to Lagom Framework
Introduction to Lagom FrameworkIntroduction to Lagom Framework
Introduction to Lagom FrameworkKnoldus Inc.
 
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
 
NetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksNetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksRuslan Meshenberg
 
All About Microservices and OpenSource Microservice Frameworks
All About Microservices and OpenSource Microservice FrameworksAll About Microservices and OpenSource Microservice Frameworks
All About Microservices and OpenSource Microservice FrameworksMohammad Asif Siddiqui
 
Drools & jBPM future roadmap talk
Drools & jBPM future roadmap talkDrools & jBPM future roadmap talk
Drools & jBPM future roadmap talkMark Proctor
 
Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC  Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC vipin kumar
 
Scale and Load Testing of Micro-Service
Scale and Load Testing of Micro-ServiceScale and Load Testing of Micro-Service
Scale and Load Testing of Micro-ServiceIRJET Journal
 
OS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of MLOS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of MLNordic APIs
 
Distributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaDistributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaMax Alexejev
 
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 - Introduction
Struts 2 - Introduction Struts 2 - Introduction
Struts 2 - Introduction Hitesh-Java
 
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...Jitendra Bafna
 

Ähnlich wie Developing Microservices using Spring - Beginner's Guide (20)

Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with java
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 
Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice framework
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSockets
 
Java one2013
Java one2013Java one2013
Java one2013
 
Introduction to Lagom Framework
Introduction to Lagom FrameworkIntroduction to Lagom Framework
Introduction to Lagom Framework
 
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
 
NetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talksNetflixOSS Open House Lightning talks
NetflixOSS Open House Lightning talks
 
All About Microservices and OpenSource Microservice Frameworks
All About Microservices and OpenSource Microservice FrameworksAll About Microservices and OpenSource Microservice Frameworks
All About Microservices and OpenSource Microservice Frameworks
 
Drools & jBPM future roadmap talk
Drools & jBPM future roadmap talkDrools & jBPM future roadmap talk
Drools & jBPM future roadmap talk
 
Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC  Cloud compiler - Minor Project by students of CBPGEC
Cloud compiler - Minor Project by students of CBPGEC
 
Scale and Load Testing of Micro-Service
Scale and Load Testing of Micro-ServiceScale and Load Testing of Micro-Service
Scale and Load Testing of Micro-Service
 
OS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of MLOS for AI: Elastic Microservices & the Next Gen of ML
OS for AI: Elastic Microservices & the Next Gen of ML
 
Distributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and ScalaDistributed & Highly Available server applications in Java and Scala
Distributed & Highly Available server applications in Java and Scala
 
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
 
Liferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for DevelopersLiferay (DXP) 7 Tech Meetup for Developers
Liferay (DXP) 7 Tech Meetup for Developers
 
AKS: k8s e azure
AKS: k8s e azureAKS: k8s e azure
AKS: k8s e azure
 
Struts 2 - Introduction
Struts 2 - Introduction Struts 2 - Introduction
Struts 2 - Introduction
 
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
MuleSoft Surat Virtual Meetup#6 - MuleSoft Project Template Using Maven Arche...
 

Kürzlich hochgeladen

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
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
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
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
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
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
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
 
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
 

Kürzlich hochgeladen (20)

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
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
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, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
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...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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
 
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
 

Developing Microservices using Spring - Beginner's Guide

  • 1. Developing Microservices using Spring - Beginners Guide * Disclaimer: There are various topics covered in this session, each topic is worth a 2 day workshop session in itself, so this will cover only the very basics and try to provide a birds eye view of the various concepts.
  • 2. Agenda ● Microservices ● What ? ● Why ? ● Challenges of a distributed system ● Building Microservices using Spring ● Spring Boot ● Spring Cloud & Netflix OSS ● Conclusion
  • 3. All Roads Lead to Microservices Cloud aPaaS Continuous Delivery Dev Ops Agile Microservices
  • 4. Microservices – What ? The term "Microservice Architecture" has sprung up over the last few years to describe a particular way of designing software applications as suites of independently deployable services. -Martin Fowler http://martinfowler.com/articles/microservices.html Microservices are loosely coupled service oriented architecture with bounded contexts. - Adrian Cockroft
  • 5. Monolith Application ● Imaginary E-Commerce App ● Very efficient inter process calls between components ● Good architecture, until it needs to scale during busy shopping season.
  • 6. Monolith Application ● You want to scale only 'Shopping Cart' and 'Checkout' Modules, but instead have to scale the entire App ● Other Challenges with multiple database and Session management
  • 7. Monolith Application – Good Parts ● Contains Everything ● Single Deployment ● Minimum viable product can be reached quickly ● Easy (or Familiar) to understand
  • 8. Monolith Application – Bad Parts ● Complex Architecture ● Difficult to Scale (cannot scale only selected modules) ● Long term commitment to one technical stack
  • 9. Microservices ● Distillation of SOA ● Single Context ● Smart Services / Dumb Pipes ● RESTful Communications ● Smaller codebase – easy to reason about ● Easy to scale
  • 11. Challenges of distributed system ● Configuration Management ● Service Registration & Discovery ● Load Balancing ● Fault Tolerance ● Monitoring ● Concurrent API Integration & Transformation *(This is not a complete list...)
  • 12. Spring Boot ● Built on top of Spring framework ● Opinionated convention over configuration ● Creates stand-alone “Production” ready app ● Embedded Tomcat / Jetty ● Various Starters POMs to simplify configuration ● https://start.spring.io/ - Spring Initializr template project (We can replace our kick start scripts with something like this)
  • 13. Spring Boot ● It can get pretty small.. @RestController class ThisWillActuallyRun { @RequestMapping("/") String home() { "Hello World!" } } Exercise 1 : Spring Boot Hello World
  • 14. Spring Boot ● Retrieve data from database – Spring Data REST ● Entity Class @Entity @Table(name="users") public class User implements Serializable{... } ● Repository Class @Repository public interface UserRepository extends JpaRepository<User, Integer> { } ● Main Class @SpringBootApplication public class SampleDataJpaApplication { public static void main(String[] args) throws Exception { SpringApplication.run(SampleDataJpaApplication.class, args); } } ● The same project runs in local and Cloud - PWS Exercise 2 : Spring Data REST
  • 15. Spring Cloud ● Writing a single service with Spring Boot is easy. ● But things gets complex with managing multiple services ● http://cloud.spring.io/spring-cloud-netflix/ , to the rescue. ● Similar to Spring Data umbrella project.
  • 16. Spring Cloud Netflix ● Configuration Management – Spring Cloud Config ● Service Registration & Discovery – Eureka ● Load Balancing – Feign & Ribbon ● Fault Tolerance (Circuit Breaker) – Hysterix ● Monitoring – Hysterix Dashboard ● Concurrent API Integration & Transformation - RxJava
  • 17. Spring Cloud Config ● Distributed configuration management. ● Provides server and client-side support for externalized configuration. ● Store Configuration properties (YAML content) in remote repository (Git supported by default) ● Curl -X POST http://localhost:8888/bus/refresh, to get the latest values from the config server. Exercise 3 : Config Server Cloud Bus (AMQP / RabbitMQ) Git (default) properties Config Server /refresh /refresh
  • 18. Service Registry & Discovery - Eureka ● Eureka is Netflix OSS Project for Service Discovery Server & Client. ● Eureka Server – can be configured to be highly available, supports server replication for resiliency. ● Clients registers with Eureka and sends heartbeat messages to Server. ● Eureka Server @EnableEurekaServer class Eureka { } ● Eureka Client @EnableDiscoveryClient public class Application {... } ● Producer Consumer example Exercise 4 : Eureka – Producer / Consumer
  • 19. Load balancing - Ribbon ● Ribbon is a Netflix OSS Project, it provides software load balancers with cluster of servers. ● Provides basic functionality like supply the public DNS name of servers to client, rotate among the list of servers according to certain logic. ● Load balancer components Rule – logic to determine which server to return from the serverlist. Ping – to ensure server liveness ServerList – can be static or dynamic ● Spring RestTemplate has been added with little bit of magic and made Ribbon enabled. ● FeignClient is alternative to Spring RestTemplate, Feign is declarative web service client, makes writing web service clients easier. Exercise 5 : Producer / Consumer example with load balancer / Feign
  • 20. Fault Tolerance - Hystrix ● Hystrix – Circuit Breaker Pattern ● Its a state machine, with 3 states – Closed, Open and Half-Open. ● Failures does not cascade up to the top of the call stack. Exercise 6 : Hystrix in action
  • 21. Monitoring ● Hystrix Dashboard Import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard @EnableHystrixDashboard class HystrixDashboard { … } Exercise 7 : Hystrix Dashboard in action
  • 22. Concurrent API Integration - RxJava ● RxJava is Java implementation of MS Reactive Extensions. ● A library for composing asynchronous and event-based programs by using Observable sequences. ● Netflix created RxJava to simplify server side concurrency, a single “heavy” client request that is executed in parallel on the server. ● The service layer API method return an Observable<T> getData(), this can be asynch or synch, and its transparent to the caller of this service. ● Can be achieved using Java Futures, but it supports one value, not for a sequences. Also calling Future.get() will be a blocking. ● Callbacks can be used for asynchronous execution and works well for single level of execution, but things gets complicated with nested Callbacks (callback hell !).
  • 23. Conclusion ● Microservices Architectural Style needs certain infrastructure competencies like, Rapid Provisioning, Continuous Delivery, Basic Monitoring, etc., ● There are many new design patterns to learn when implementing a distributed system. ● Spring Cloud Netflix implements certain patterns and Spring Boot makes it easy to use.
  • 24. References ● http://martinfowler.com/articles/microservices.html ● http://martinfowler.com/bliki/MicroservicePrerequisites.html ● http://projects.spring.io/spring-boot/ ● http://projects.spring.io/spring-cloud/ ● http://cloud.spring.io/spring-cloud-netflix/ ● http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html ● https://github.com/ReactiveX/RxJava ● http://www.infoq.com/presentations/reactive-arch-grails ● http://www.infoq.com/presentations/Netflix-API-rxjava-hystrix Images ● https://www.flickr.com/photos/bhophoto/384574407/