SlideShare a Scribd company logo
Firmansyah.profess@gmail.com
2018
Eclipse Vert.x
Chapter 03
HTTP Based Microservices
00. Sequence Diagram
We will create two verticle classes with following
sequence diagram to demonstrate HTTP based
Microservices
HttpMicro02 HttpMicro01
HTTP Request
HTTP Request /Firmansyah
HTTP Request /Indonesia
HTTP Response “hello Firmansyah”
HTTP Response “hello Indonesia”
HTTP Response
01. Create HttpMicro01 Class
a. Create a directory called “chapter03”
b. Generate the project structure using
maven inside chapter03 folder:
mvn io.fabric8:vertx-maven-plugin:1.0.5:setup 
-DprojectGroupId=io.vertx.chapter03 
-DprojectArtifactId=http-micro-vertx-app 
-Dverticle=io.vertx.chapter03.HttpMicro01 
-Ddependencies=web
This command generates:
1. The Maven project structure,
2. Configures the vertx-maven-plugin, and
3. Creates a verticle class (io.vertx.chapter03.HttpMicro01),
4. Adds the vertx-web dependency, Vert.x Web is a module
that provides everything you need to build modern web
applications on top of Vert.x.
01. Create HttpMicro01 Class
c. Modify io.vertx.chapter03.HttpMicro01 Class
1. Create method for JSON HTTP response (Vert.x provides a
JsonObject class to create and manipulate JSON
structures.):
private void helloJson(RoutingContext rc) {
String message = "hello";
if (rc.pathParam("name") != null) {
message += " " + rc.pathParam("name");
}
JsonObject json = new JsonObject().put("message", message);
rc.response()
.putHeader(HttpHeaders.CONTENT_TYPE, "application/json")
.end(json.encode());
}
2. Add logic for HTTP Server creation, routes and
parameters request handling inside the start()
method:
01. Create HttpMicro01 Class
public void start() {
Router router = Router.router(vertx);
router.get("/").handler(this::helloJson);
router.get("/:name").handler(this::helloJson);
vertx.createHttpServer()
.requestHandler(router::accept)
.listen(8080);
}
Notes:
• This code creates an HTTP server on port 8080 and registers a
requestHandler and use the accept method of the router.
• Vert.x Web provides a Router on which we can register Routes.
Routes are the mechanism by which Vert.x Web checks the path
and invokes the associated action.
• Once we have created the Router object, we register two
routes. The first one handles requests on / and just writes
hello. The second route has a path parameter (:name).
The handler will call helloJson to return JSON response
01. Create HttpMicro01 Class
d. Package app as a fat jar, launch:
mvn clean package
e. Run this application, launch:
java -jar target/http-micro-vertx-app-1.0-SNAPSHOT.jar
f. Browse URL http://localhost:8080/ and look at
the application output.
g. Use Ctrl + C to shut down.
02. Create HttpMicro02 Class
a. Create a directory called “consumer” inside
chapter03 folder
b. Generate the new project structure using
maven inside consumer folder:
mvn io.fabric8:vertx-maven-plugin:1.0.5:setup 
-DprojectGroupId=io.vertx.chapter03 
-DprojectArtifactId=http-micro02-vertx-app 
-Dverticle=io.vertx.chapter03.HttpMicro02 
-Ddependencies=web,web-client,rx
Notes:
1. The last command adds another dependency: the Vert.x web
client, an asynchronous HTTP client. We will use this client
to call the first microservice (HttpMicro01 class).
2. The command has also added the Vert.x RxJava binding.
02. Create HttpMicro02 Class
c. Modify io.vertx.chapter03.HttpMicro02
1. In the start method, we create a WebClient and a Router.
2. On the created router, we register a route on “/” and start the
HTTP server, passing the router accept method as
requestHandler.
3. The handler of the route is a method
invokeHttpMicro01() with following logic:
• Uses the web client to invoke the first microservice with a
specific path (/firmansyah)
• The handler we passed in into request.send() is
invoked when either the response arrives or an error
occurs.
• When it succeeds, we write the received payload to the
response; otherwise, we reply with a 500 response
Thank You!
Any questions? You can find me at
firmansyah.profess@gmail.com
Credits
PPT: ALLPPT.com
Music: https://www.bensound.com
Chapter 03: Eclipse Vert.x - HTTP Based Microservices

More Related Content

What's hot

Asp.net page lifecycle
Asp.net page lifecycleAsp.net page lifecycle
Asp.net page lifecycle
KhademulBasher
 
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
( 16 ) Office 2007   Create An Extranet Site With Forms Authentication( 16 ) Office 2007   Create An Extranet Site With Forms Authentication
( 16 ) Office 2007 Create An Extranet Site With Forms AuthenticationLiquidHub
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
Parag Mujumdar
 
Servlet LifeCycle Demo App
Servlet LifeCycle Demo  AppServlet LifeCycle Demo  App
Servlet LifeCycle Demo AppPeeyush Ranjan
 
KOIN for dependency Injection
KOIN for dependency InjectionKOIN for dependency Injection
KOIN for dependency Injection
Kirill Rozov
 
ASP.NET Page life cycle and ViewState
ASP.NET Page life cycle and ViewStateASP.NET Page life cycle and ViewState
ASP.NET Page life cycle and ViewState
Mindfire Solutions
 
Get started with meteor | designveloper software agency meteor prime partner
Get started with meteor | designveloper software agency   meteor prime partnerGet started with meteor | designveloper software agency   meteor prime partner
Get started with meteor | designveloper software agency meteor prime partner
Designveloper
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
Jeevesh Pandey
 
Migration from vaadin 6 to vaadin 7 devoxx france 2013
Migration from vaadin 6 to vaadin 7   devoxx france 2013Migration from vaadin 6 to vaadin 7   devoxx france 2013
Migration from vaadin 6 to vaadin 7 devoxx france 2013
Joonas Lehtinen
 

What's hot (9)

Asp.net page lifecycle
Asp.net page lifecycleAsp.net page lifecycle
Asp.net page lifecycle
 
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
( 16 ) Office 2007   Create An Extranet Site With Forms Authentication( 16 ) Office 2007   Create An Extranet Site With Forms Authentication
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
Servlet LifeCycle Demo App
Servlet LifeCycle Demo  AppServlet LifeCycle Demo  App
Servlet LifeCycle Demo App
 
KOIN for dependency Injection
KOIN for dependency InjectionKOIN for dependency Injection
KOIN for dependency Injection
 
ASP.NET Page life cycle and ViewState
ASP.NET Page life cycle and ViewStateASP.NET Page life cycle and ViewState
ASP.NET Page life cycle and ViewState
 
Get started with meteor | designveloper software agency meteor prime partner
Get started with meteor | designveloper software agency   meteor prime partnerGet started with meteor | designveloper software agency   meteor prime partner
Get started with meteor | designveloper software agency meteor prime partner
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Migration from vaadin 6 to vaadin 7 devoxx france 2013
Migration from vaadin 6 to vaadin 7   devoxx france 2013Migration from vaadin 6 to vaadin 7   devoxx france 2013
Migration from vaadin 6 to vaadin 7 devoxx france 2013
 

Similar to Chapter 03: Eclipse Vert.x - HTTP Based Microservices

Chapter 04: Eclipse Vert.x - Message Based Microservices
Chapter 04: Eclipse Vert.x - Message Based MicroservicesChapter 04: Eclipse Vert.x - Message Based Microservices
Chapter 04: Eclipse Vert.x - Message Based Microservices
Firmansyah, SCJP, OCEWCD, OCEWSD, TOGAF, OCMJEA, CEH
 
maven-for-maine-jug-090226091601-phpapp02.ppt
maven-for-maine-jug-090226091601-phpapp02.pptmaven-for-maine-jug-090226091601-phpapp02.ppt
maven-for-maine-jug-090226091601-phpapp02.ppt
nikhilmahendranath1
 
Meteor
MeteorMeteor
Meteor
Noam Kfir
 
Struts tutorial
Struts tutorialStruts tutorial
Struts tutorial
OPENLANE
 
B14870 solution final
B14870 solution finalB14870 solution final
B14870 solution final
ssuser8f0495
 
Fundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdfFundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdf
StephieJohn
 
M2ModuleDevelopmenteBook
M2ModuleDevelopmenteBookM2ModuleDevelopmenteBook
M2ModuleDevelopmenteBookTrọng Huỳnh
 
Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...
naseeb20
 
Rest web service_with_spring_hateoas
Rest web service_with_spring_hateoasRest web service_with_spring_hateoas
Rest web service_with_spring_hateoas
Zeid Hassan
 
LearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLLearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLAkhil Mittal
 
React js
React jsReact js
React js
Rajesh Kolla
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_cs
Alfa Gama Omega
 
A Java Microservices Spring Boot and Docker case study.
A Java Microservices Spring Boot and Docker case study.A Java Microservices Spring Boot and Docker case study.
A Java Microservices Spring Boot and Docker case study.
Subramanyam Vemala
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
StephieJohn
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
jinaldesailive
 
Java microservicesdockerdockerhubusecase2
Java microservicesdockerdockerhubusecase2Java microservicesdockerdockerhubusecase2
Java microservicesdockerdockerhubusecase2
Subramanyam Vemala
 
Meteor.js Workshop by Dopravo
Meteor.js Workshop by DopravoMeteor.js Workshop by Dopravo
Meteor.js Workshop by Dopravo
ArabNet ME
 

Similar to Chapter 03: Eclipse Vert.x - HTTP Based Microservices (20)

Chapter 04: Eclipse Vert.x - Message Based Microservices
Chapter 04: Eclipse Vert.x - Message Based MicroservicesChapter 04: Eclipse Vert.x - Message Based Microservices
Chapter 04: Eclipse Vert.x - Message Based Microservices
 
maven-for-maine-jug-090226091601-phpapp02.ppt
maven-for-maine-jug-090226091601-phpapp02.pptmaven-for-maine-jug-090226091601-phpapp02.ppt
maven-for-maine-jug-090226091601-phpapp02.ppt
 
Meteor
MeteorMeteor
Meteor
 
Struts tutorial
Struts tutorialStruts tutorial
Struts tutorial
 
B14870 solution final
B14870 solution finalB14870 solution final
B14870 solution final
 
Servlets
ServletsServlets
Servlets
 
Fundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdfFundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdf
 
M2ModuleDevelopmenteBook
M2ModuleDevelopmenteBookM2ModuleDevelopmenteBook
M2ModuleDevelopmenteBook
 
Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...
 
Building richwebapplicationsusingasp
Building richwebapplicationsusingaspBuilding richwebapplicationsusingasp
Building richwebapplicationsusingasp
 
Rest web service_with_spring_hateoas
Rest web service_with_spring_hateoasRest web service_with_spring_hateoas
Rest web service_with_spring_hateoas
 
LearningMVCWithLINQToSQL
LearningMVCWithLINQToSQLLearningMVCWithLINQToSQL
LearningMVCWithLINQToSQL
 
React js
React jsReact js
React js
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_cs
 
A Java Microservices Spring Boot and Docker case study.
A Java Microservices Spring Boot and Docker case study.A Java Microservices Spring Boot and Docker case study.
A Java Microservices Spring Boot and Docker case study.
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
 
Java microservicesdockerdockerhubusecase2
Java microservicesdockerdockerhubusecase2Java microservicesdockerdockerhubusecase2
Java microservicesdockerdockerhubusecase2
 
Jdbc
JdbcJdbc
Jdbc
 
Meteor.js Workshop by Dopravo
Meteor.js Workshop by DopravoMeteor.js Workshop by Dopravo
Meteor.js Workshop by Dopravo
 

More from Firmansyah, SCJP, OCEWCD, OCEWSD, TOGAF, OCMJEA, CEH

Microservices Decomposition Patterns.v1.0.20191009
Microservices Decomposition Patterns.v1.0.20191009Microservices Decomposition Patterns.v1.0.20191009
Microservices Decomposition Patterns.v1.0.20191009
Firmansyah, SCJP, OCEWCD, OCEWSD, TOGAF, OCMJEA, CEH
 
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK.v1.0.20191009
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK.v1.0.20191009Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK.v1.0.20191009
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK.v1.0.20191009
Firmansyah, SCJP, OCEWCD, OCEWSD, TOGAF, OCMJEA, CEH
 
Microservices Decomposition Patterns
Microservices Decomposition PatternsMicroservices Decomposition Patterns
Microservices Decomposition Patterns
Firmansyah, SCJP, OCEWCD, OCEWSD, TOGAF, OCMJEA, CEH
 
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDKComparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK
Firmansyah, SCJP, OCEWCD, OCEWSD, TOGAF, OCMJEA, CEH
 
Chapter 06: Eclipse Vert.x - Reactive Microservices with OpenShift
Chapter 06: Eclipse Vert.x - Reactive Microservices with OpenShiftChapter 06: Eclipse Vert.x - Reactive Microservices with OpenShift
Chapter 06: Eclipse Vert.x - Reactive Microservices with OpenShift
Firmansyah, SCJP, OCEWCD, OCEWSD, TOGAF, OCMJEA, CEH
 
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
Firmansyah, SCJP, OCEWCD, OCEWSD, TOGAF, OCMJEA, CEH
 
Liferay Platform Overview
Liferay Platform OverviewLiferay Platform Overview
Solution Architecture Framework
Solution Architecture FrameworkSolution Architecture Framework
Solution Architecture Definition
Solution Architecture DefinitionSolution Architecture Definition
Mobile Application Development Platform 2017
Mobile Application Development Platform 2017Mobile Application Development Platform 2017
Mobile Application Development Platform 2017
Firmansyah, SCJP, OCEWCD, OCEWSD, TOGAF, OCMJEA, CEH
 

More from Firmansyah, SCJP, OCEWCD, OCEWSD, TOGAF, OCMJEA, CEH (10)

Microservices Decomposition Patterns.v1.0.20191009
Microservices Decomposition Patterns.v1.0.20191009Microservices Decomposition Patterns.v1.0.20191009
Microservices Decomposition Patterns.v1.0.20191009
 
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK.v1.0.20191009
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK.v1.0.20191009Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK.v1.0.20191009
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK.v1.0.20191009
 
Microservices Decomposition Patterns
Microservices Decomposition PatternsMicroservices Decomposition Patterns
Microservices Decomposition Patterns
 
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDKComparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK
Comparison between Oracle JDK, Oracle OpenJDK, and Red Hat OpenJDK
 
Chapter 06: Eclipse Vert.x - Reactive Microservices with OpenShift
Chapter 06: Eclipse Vert.x - Reactive Microservices with OpenShiftChapter 06: Eclipse Vert.x - Reactive Microservices with OpenShift
Chapter 06: Eclipse Vert.x - Reactive Microservices with OpenShift
 
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
Chapter 05: Eclipse Vert.x - Service Discovery, Resilience and Stability Patt...
 
Liferay Platform Overview
Liferay Platform OverviewLiferay Platform Overview
Liferay Platform Overview
 
Solution Architecture Framework
Solution Architecture FrameworkSolution Architecture Framework
Solution Architecture Framework
 
Solution Architecture Definition
Solution Architecture DefinitionSolution Architecture Definition
Solution Architecture Definition
 
Mobile Application Development Platform 2017
Mobile Application Development Platform 2017Mobile Application Development Platform 2017
Mobile Application Development Platform 2017
 

Recently uploaded

In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 

Recently uploaded (20)

In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 

Chapter 03: Eclipse Vert.x - HTTP Based Microservices

  • 2. 00. Sequence Diagram We will create two verticle classes with following sequence diagram to demonstrate HTTP based Microservices HttpMicro02 HttpMicro01 HTTP Request HTTP Request /Firmansyah HTTP Request /Indonesia HTTP Response “hello Firmansyah” HTTP Response “hello Indonesia” HTTP Response
  • 3. 01. Create HttpMicro01 Class a. Create a directory called “chapter03” b. Generate the project structure using maven inside chapter03 folder: mvn io.fabric8:vertx-maven-plugin:1.0.5:setup -DprojectGroupId=io.vertx.chapter03 -DprojectArtifactId=http-micro-vertx-app -Dverticle=io.vertx.chapter03.HttpMicro01 -Ddependencies=web This command generates: 1. The Maven project structure, 2. Configures the vertx-maven-plugin, and 3. Creates a verticle class (io.vertx.chapter03.HttpMicro01), 4. Adds the vertx-web dependency, Vert.x Web is a module that provides everything you need to build modern web applications on top of Vert.x.
  • 4. 01. Create HttpMicro01 Class c. Modify io.vertx.chapter03.HttpMicro01 Class 1. Create method for JSON HTTP response (Vert.x provides a JsonObject class to create and manipulate JSON structures.): private void helloJson(RoutingContext rc) { String message = "hello"; if (rc.pathParam("name") != null) { message += " " + rc.pathParam("name"); } JsonObject json = new JsonObject().put("message", message); rc.response() .putHeader(HttpHeaders.CONTENT_TYPE, "application/json") .end(json.encode()); } 2. Add logic for HTTP Server creation, routes and parameters request handling inside the start() method:
  • 5. 01. Create HttpMicro01 Class public void start() { Router router = Router.router(vertx); router.get("/").handler(this::helloJson); router.get("/:name").handler(this::helloJson); vertx.createHttpServer() .requestHandler(router::accept) .listen(8080); } Notes: • This code creates an HTTP server on port 8080 and registers a requestHandler and use the accept method of the router. • Vert.x Web provides a Router on which we can register Routes. Routes are the mechanism by which Vert.x Web checks the path and invokes the associated action. • Once we have created the Router object, we register two routes. The first one handles requests on / and just writes hello. The second route has a path parameter (:name). The handler will call helloJson to return JSON response
  • 6. 01. Create HttpMicro01 Class d. Package app as a fat jar, launch: mvn clean package e. Run this application, launch: java -jar target/http-micro-vertx-app-1.0-SNAPSHOT.jar f. Browse URL http://localhost:8080/ and look at the application output. g. Use Ctrl + C to shut down.
  • 7. 02. Create HttpMicro02 Class a. Create a directory called “consumer” inside chapter03 folder b. Generate the new project structure using maven inside consumer folder: mvn io.fabric8:vertx-maven-plugin:1.0.5:setup -DprojectGroupId=io.vertx.chapter03 -DprojectArtifactId=http-micro02-vertx-app -Dverticle=io.vertx.chapter03.HttpMicro02 -Ddependencies=web,web-client,rx Notes: 1. The last command adds another dependency: the Vert.x web client, an asynchronous HTTP client. We will use this client to call the first microservice (HttpMicro01 class). 2. The command has also added the Vert.x RxJava binding.
  • 8. 02. Create HttpMicro02 Class c. Modify io.vertx.chapter03.HttpMicro02 1. In the start method, we create a WebClient and a Router. 2. On the created router, we register a route on “/” and start the HTTP server, passing the router accept method as requestHandler. 3. The handler of the route is a method invokeHttpMicro01() with following logic: • Uses the web client to invoke the first microservice with a specific path (/firmansyah) • The handler we passed in into request.send() is invoked when either the response arrives or an error occurs. • When it succeeds, we write the received payload to the response; otherwise, we reply with a 500 response
  • 9. Thank You! Any questions? You can find me at firmansyah.profess@gmail.com Credits PPT: ALLPPT.com Music: https://www.bensound.com