SlideShare a Scribd company logo
1 of 41
Download to read offline
Development with Vert.x:
an event-driven application
framework for the JVM
David Wu
@wuman
blog.wu-man.com
Taiwan Java User Group (2013/06/29)
1Monday, July 1, 13
about.me/wuman
2Monday, July 1, 13
What is Vert.x?
3Monday, July 1, 13
What most people will tell you about Vert.x
• A general-purpose application framework
running on JVM
• Performant: asynchronous APIs, event-driven,
non-blocking, etc.
• Highly scalable but also easy to implement
concurrency
• Polyglot: intermix Java, JS, Ruby, Groovy,
Python, etc.
4Monday, July 1, 13
What I think about Vert.x
• All-in-one framework that allows you to focus
on your application rather than fiddling with
different technologies
• Business friendly Apache License 2.0
• Loose coupling modules that interoperate in a
system
5Monday, July 1, 13
Background on the
C10K Problem
6Monday, July 1, 13
Shift from Threading
to Asynchronous
the story of switching from Apache to Node.js
7Monday, July 1, 13
The inevitable comparison to Node.js
• A single event loop serving a high volume of
connections via an asynchronous
programming model
• Most of the real work are done in a pool of
background threads
8Monday, July 1, 13
Asynchronous Programming Model
vertx.createHttpServer().requestHandler(
new Handler<HttpServerRequest>() {
public void handle(HttpServerRequest request) {
log.info("A request has arrived on the server!");
request.response().end();
}
}
).listen(8080, "localhost");
9Monday, July 1, 13
But there are 3
problems with Node.js
10Monday, July 1, 13
Problems with Node.js
• Well, it’s not Java (and this is a Java User
Group)
• Does not easily scale both vertically and
horizontally
• Single event loop fails when you have CPU-
intensive tasks or 3rd-party blocking APIs
11Monday, July 1, 13
Vert.x to the rescue
• Use all available cores on a single machine
• Horizontally scale out to multiple boxes
• Allow blocking calls to NOT run on an event
loop
12Monday, July 1, 13
Introduction to Vert.x instance and Verticles
Verticle
Verticle
WorkerVerticle
WorkerVerticle
Vert.x instance
13Monday, July 1, 13
Verticles are extremely isolated
• Verticles are isolated with separate class
loaders
• A verticle never gets executed by more than
one thread concurrently
• No race conditions, no deadlocks. You write
your code as single threaded.
14Monday, July 1, 13
What about
communication?
15Monday, July 1, 13
Message Passing via the Event Bus
Verticle
Verticle
Worker
Verticle
Worker
Verticle
Vert.x instance
16Monday, July 1, 13
Very Powerful Event Bus
Verticle
Verticle
WorkerVerticle
Verticle
Verticle
WorkerVerticle
17Monday, July 1, 13
Registering a Message Handler
EventBus eb = vertx.eventBus();
Handler<Message> myHandler = new Handler<Message>() {
public void handle(Message message) {
System.out.println("I received a message " + message.body);
}
};
eb.registerHandler("test.address", myHandler);
18Monday, July 1, 13
Message Types
• Primitives and their boxed types
• String
• org.vertx.java.core.json.JsonObject
• org.vertx.java.core.json.JsonArray
• org.vertx.java.core.buffer.Buffer
19Monday, July 1, 13
Pub/Sub Model
eb.publish("test.address", "hello world");
20Monday, July 1, 13
Point-to-Point Model
eb.send("test.address", "This is a message",
new Handler<Message<String>>() {
public void handle(Message<String> message) {
System.out.println("I received a reply " + message.body);
}
});
EventBus eb = vertx.eventBus();
Handler<Message> myHandler = new Handler<Message>() {
public void handle(Message message) {
System.out.println("I received a message " + message.body);
message.reply("This is a reply");
}
};
eb.registerHandler("test.address", myHandler);
21Monday, July 1, 13
Shared Maps and Sets
ConcurrentMap<String, Integer> map = vertx.sharedData().getMap("demo.mymap");
map.put("some-key", 123);
Set<String> set = vertx.sharedData().getSet("demo.myset");
set.add("some-value");
22Monday, July 1, 13
Module System
23Monday, July 1, 13
Writing Verticles
import org.vertx.java.core.Handler;
import org.vertx.java.core.net.NetSocket;
import org.vertx.java.core.streams.Pump;
import org.vertx.java.platform.Verticle;
public class Server extends Verticle {
public void start() {
vertx.createNetServer().connectHandler(new Handler<NetSocket>() {
public void handle(final NetSocket socket) {
Pump.createPump(socket, socket).start();
}
}).listen(1234);
}
}
vertx run Server.java
24Monday, July 1, 13
Deploying Verticles programmatically
// For example - deploy some other verticle
container.deployVerticle("foo.js", new AsyncResultHandler<String>() {
public void handle(AsyncResult<String> deployResult) {
if (deployResult.succeeded()) {
System.out.println(“Yay!”);
} else {
System.out.println(“Error: “ + deployResult.cause());
}
}
});
25Monday, July 1, 13
Modules
• Package verticles into re-usable modules
• Simply a zip file containing module definition,
code, and resources
• Very similar to the module system in Node.js
• Modules can be “zip” artifacts released in
Maven Central
• Vert.x web site maintains a listing of Vert.x
modules
26Monday, July 1, 13
Example Modules
• JDBC, Redis, MongoDB Persistors
• AMQP
• Mailer
• Persistent work queue
• Authentication Manager
• Session Manager
• Web framework
• Language implementations
27Monday, July 1, 13
Programming
Experience
28Monday, July 1, 13
Core APIs
• TCP/SSL servers
and clients
• HTTP/HTTPS
servers and clients
• WebSockets
servers and clients
• SockJS
• EventBus
• Shared Maps and
Sets
• Buffers
• Flow control
• Timers
• Files
• Configuration
29Monday, July 1, 13
Container API
• Deploying and undeploying verticles
• Deploying and undeploying modules
• Logging
• Retrieve verticle configuration
30Monday, July 1, 13
Easy development
• Gradle template
• Maven archetype and plugin
• IDE debugging and testing
31Monday, July 1, 13
What is it good for?
32Monday, July 1, 13
Applications
• Realtime analytics dashboard
• Big data queries and task coordination
• Polyglot integration
33Monday, July 1, 13
Some Pain Points
34Monday, July 1, 13
Real life caveats
• Content assist in IDEs don’t work for busmod APIs
• You often find yourself tracing errors in the busmods,
which can be difficult because the stack trace stops
at message passing
• People writing in other languages often get frustrated
by not being able to use native extensions that they
are already used to.
• Hell of anonymous inner class callbacks and no good
Java flow control libraries
• Java7 only. Doesn’t work on Android.
35Monday, July 1, 13
Conclusion
36Monday, July 1, 13
37Monday, July 1, 13
“Using a bleeding-edge
framework is exciting at first.
Not so much afterwards.”
David Wu
37Monday, July 1, 13
Make it better.
Contribute.
http://vert-x.github.io/
38Monday, July 1, 13
Thank you
39Monday, July 1, 13
Q & A
40Monday, July 1, 13

More Related Content

What's hot

JUDCon Brazil 2013 - Vert.x an introduction
JUDCon Brazil 2013 - Vert.x an introductionJUDCon Brazil 2013 - Vert.x an introduction
JUDCon Brazil 2013 - Vert.x an introductionSamuel Tauil
 
An Introduction to the Vert.x framework
An Introduction to the Vert.x frameworkAn Introduction to the Vert.x framework
An Introduction to the Vert.x frameworkzznate
 
Event driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetesEvent driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetesAndy Moncsek
 
vert.x - life beyond jetty and apache
vert.x - life beyond jetty and apachevert.x - life beyond jetty and apache
vert.x - life beyond jetty and apacheRalph Winzinger
 
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...jaxLondonConference
 
Reactor grails realtime web devoxx 2013
Reactor grails realtime web   devoxx 2013Reactor grails realtime web   devoxx 2013
Reactor grails realtime web devoxx 2013Stéphane Maldini
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaNurul Ferdous
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?Ovidiu Dimulescu
 
Running JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java WorldRunning JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java Worldirbull
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureColin Mackay
 
Modern app programming with RxJava and Eclipse Vert.x
Modern app programming with RxJava and Eclipse Vert.xModern app programming with RxJava and Eclipse Vert.x
Modern app programming with RxJava and Eclipse Vert.xThomas Segismont
 
Nuxeo World Session: Scaling Nuxeo Applications
Nuxeo World Session: Scaling Nuxeo ApplicationsNuxeo World Session: Scaling Nuxeo Applications
Nuxeo World Session: Scaling Nuxeo ApplicationsNuxeo
 
Introducing Apricot, The Eclipse Content Management Platform
Introducing Apricot, The Eclipse Content Management PlatformIntroducing Apricot, The Eclipse Content Management Platform
Introducing Apricot, The Eclipse Content Management PlatformNuxeo
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialTom Croucher
 
Vagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundVagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundHendrik Ebbers
 

What's hot (20)

JUDCon Brazil 2013 - Vert.x an introduction
JUDCon Brazil 2013 - Vert.x an introductionJUDCon Brazil 2013 - Vert.x an introduction
JUDCon Brazil 2013 - Vert.x an introduction
 
An Introduction to the Vert.x framework
An Introduction to the Vert.x frameworkAn Introduction to the Vert.x framework
An Introduction to the Vert.x framework
 
Event driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetesEvent driven microservices with vertx and kubernetes
Event driven microservices with vertx and kubernetes
 
vert.x - life beyond jetty and apache
vert.x - life beyond jetty and apachevert.x - life beyond jetty and apache
vert.x - life beyond jetty and apache
 
Vert.x vs akka
Vert.x vs akkaVert.x vs akka
Vert.x vs akka
 
Production ready Vert.x
Production ready Vert.xProduction ready Vert.x
Production ready Vert.x
 
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
Introducing Vert.x 2.0 - Taking polyglot application development to the next ...
 
Reactor grails realtime web devoxx 2013
Reactor grails realtime web   devoxx 2013Reactor grails realtime web   devoxx 2013
Reactor grails realtime web devoxx 2013
 
Vertx in production
Vertx in productionVertx in production
Vertx in production
 
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, DhakaJavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
JavaScript as a Server side language (NodeJS): JSConf 2011, Dhaka
 
Vertx
VertxVertx
Vertx
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?
 
Running JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java WorldRunning JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java World
 
Introduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azureIntroduction to node js - From "hello world" to deploying on azure
Introduction to node js - From "hello world" to deploying on azure
 
Modern app programming with RxJava and Eclipse Vert.x
Modern app programming with RxJava and Eclipse Vert.xModern app programming with RxJava and Eclipse Vert.x
Modern app programming with RxJava and Eclipse Vert.x
 
Building Reactive Microservices with Vert.x
Building Reactive Microservices with Vert.xBuilding Reactive Microservices with Vert.x
Building Reactive Microservices with Vert.x
 
Nuxeo World Session: Scaling Nuxeo Applications
Nuxeo World Session: Scaling Nuxeo ApplicationsNuxeo World Session: Scaling Nuxeo Applications
Nuxeo World Session: Scaling Nuxeo Applications
 
Introducing Apricot, The Eclipse Content Management Platform
Introducing Apricot, The Eclipse Content Management PlatformIntroducing Apricot, The Eclipse Content Management Platform
Introducing Apricot, The Eclipse Content Management Platform
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Vagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundVagrant-Binding JUG Dortmund
Vagrant-Binding JUG Dortmund
 

Viewers also liked

Vert.x v3 - high performance polyglot application toolkit
Vert.x v3 - high performance  polyglot application toolkitVert.x v3 - high performance  polyglot application toolkit
Vert.x v3 - high performance polyglot application toolkitSages
 
Reactive Distributed Applications with Vert.x
Reactive Distributed Applications with Vert.xReactive Distributed Applications with Vert.x
Reactive Distributed Applications with Vert.xRed Hat Developers
 
ADF in Action - getting (re)acquainted with Oracle’s premier application deve...
ADF in Action - getting (re)acquainted with Oracle’s premier application deve...ADF in Action - getting (re)acquainted with Oracle’s premier application deve...
ADF in Action - getting (re)acquainted with Oracle’s premier application deve...Lucas Jellema
 
Build your reactive web application with Vert.x
Build your reactive web application with Vert.xBuild your reactive web application with Vert.x
Build your reactive web application with Vert.xCodemotion
 
Data Caching Strategies for Oracle Mobile Application Framework
Data Caching Strategies for Oracle Mobile Application FrameworkData Caching Strategies for Oracle Mobile Application Framework
Data Caching Strategies for Oracle Mobile Application Frameworkandrejusb
 
Gws 20131018 vertx_handson(updated)
Gws 20131018 vertx_handson(updated)Gws 20131018 vertx_handson(updated)
Gws 20131018 vertx_handson(updated)Nobuhiro Sue
 
Real World Enterprise Reactive Programming using Vert.x
Real World Enterprise Reactive Programming using Vert.xReal World Enterprise Reactive Programming using Vert.x
Real World Enterprise Reactive Programming using Vert.xMariam Hakobyan
 
Case study - Nuskin: Statefull Applications in a Stateless World
Case study - Nuskin: Statefull Applications in a Stateless WorldCase study - Nuskin: Statefull Applications in a Stateless World
Case study - Nuskin: Statefull Applications in a Stateless WorldDay Software
 
Futures and Rx Observables: powerful abstractions for consuming web services ...
Futures and Rx Observables: powerful abstractions for consuming web services ...Futures and Rx Observables: powerful abstractions for consuming web services ...
Futures and Rx Observables: powerful abstractions for consuming web services ...Chris Richardson
 
Managing computational resources with Apache Mesos
Managing computational resources with Apache MesosManaging computational resources with Apache Mesos
Managing computational resources with Apache MesosJackson dos Santos Olveira
 
PC = Personal Cloud (or how to use your development machine with Vagrant and ...
PC = Personal Cloud (or how to use your development machine with Vagrant and ...PC = Personal Cloud (or how to use your development machine with Vagrant and ...
PC = Personal Cloud (or how to use your development machine with Vagrant and ...Codemotion
 

Viewers also liked (20)

Vert.x v3 - high performance polyglot application toolkit
Vert.x v3 - high performance  polyglot application toolkitVert.x v3 - high performance  polyglot application toolkit
Vert.x v3 - high performance polyglot application toolkit
 
Reactive Distributed Applications with Vert.x
Reactive Distributed Applications with Vert.xReactive Distributed Applications with Vert.x
Reactive Distributed Applications with Vert.x
 
ADF in Action - getting (re)acquainted with Oracle’s premier application deve...
ADF in Action - getting (re)acquainted with Oracle’s premier application deve...ADF in Action - getting (re)acquainted with Oracle’s premier application deve...
ADF in Action - getting (re)acquainted with Oracle’s premier application deve...
 
Build your reactive web application with Vert.x
Build your reactive web application with Vert.xBuild your reactive web application with Vert.x
Build your reactive web application with Vert.x
 
Data Caching Strategies for Oracle Mobile Application Framework
Data Caching Strategies for Oracle Mobile Application FrameworkData Caching Strategies for Oracle Mobile Application Framework
Data Caching Strategies for Oracle Mobile Application Framework
 
Mech project list
Mech project listMech project list
Mech project list
 
Gws 20131018 vertx_handson(updated)
Gws 20131018 vertx_handson(updated)Gws 20131018 vertx_handson(updated)
Gws 20131018 vertx_handson(updated)
 
Real World Enterprise Reactive Programming using Vert.x
Real World Enterprise Reactive Programming using Vert.xReal World Enterprise Reactive Programming using Vert.x
Real World Enterprise Reactive Programming using Vert.x
 
Vertx
VertxVertx
Vertx
 
Case study - Nuskin: Statefull Applications in a Stateless World
Case study - Nuskin: Statefull Applications in a Stateless WorldCase study - Nuskin: Statefull Applications in a Stateless World
Case study - Nuskin: Statefull Applications in a Stateless World
 
Vert.x 3
Vert.x 3Vert.x 3
Vert.x 3
 
Futures and Rx Observables: powerful abstractions for consuming web services ...
Futures and Rx Observables: powerful abstractions for consuming web services ...Futures and Rx Observables: powerful abstractions for consuming web services ...
Futures and Rx Observables: powerful abstractions for consuming web services ...
 
Docker hub
Docker hubDocker hub
Docker hub
 
Apache mahout - introduction
Apache mahout - introductionApache mahout - introduction
Apache mahout - introduction
 
Managing computational resources with Apache Mesos
Managing computational resources with Apache MesosManaging computational resources with Apache Mesos
Managing computational resources with Apache Mesos
 
Vagrant
VagrantVagrant
Vagrant
 
An introduction to predictionIO
An introduction to predictionIOAn introduction to predictionIO
An introduction to predictionIO
 
Docker cloud
Docker cloudDocker cloud
Docker cloud
 
PC = Personal Cloud (or how to use your development machine with Vagrant and ...
PC = Personal Cloud (or how to use your development machine with Vagrant and ...PC = Personal Cloud (or how to use your development machine with Vagrant and ...
PC = Personal Cloud (or how to use your development machine with Vagrant and ...
 
Introduction to CFEngine
Introduction to CFEngineIntroduction to CFEngine
Introduction to CFEngine
 

Similar to Development with Vert.x: an event-driven application framework for the JVM

MvvmCross Introduction
MvvmCross IntroductionMvvmCross Introduction
MvvmCross IntroductionStuart Lodge
 
MvvmCross Seminar
MvvmCross SeminarMvvmCross Seminar
MvvmCross SeminarXamarin
 
Node.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNode.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNaveen S.R
 
Demystifying Containerization Principles for Data Scientists
Demystifying Containerization Principles for Data ScientistsDemystifying Containerization Principles for Data Scientists
Demystifying Containerization Principles for Data ScientistsDr Ganesh Iyer
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jibanJibanananda Sana
 
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx75waytechnologies
 
Surrogate dependencies (in node js) v1.0
Surrogate dependencies  (in node js)  v1.0Surrogate dependencies  (in node js)  v1.0
Surrogate dependencies (in node js) v1.0Dinis Cruz
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivRon Perlmuter
 
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondBuilding APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondRick G. Garibay
 
Quick introduction to nodeJs
Quick introduction to nodeJsQuick introduction to nodeJs
Quick introduction to nodeJsAram Rafeq
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...mfrancis
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node jsHabilelabs
 
Apereo OAE - Architectural overview
Apereo OAE - Architectural overviewApereo OAE - Architectural overview
Apereo OAE - Architectural overviewNicolaas Matthijs
 
Dockers and kubernetes
Dockers and kubernetesDockers and kubernetes
Dockers and kubernetesDr Ganesh Iyer
 
An introduction to Node.js application development
An introduction to Node.js application developmentAn introduction to Node.js application development
An introduction to Node.js application developmentshelloidhq
 
Is OSGi Modularity Always Worth It? - Glyn Normington
Is OSGi Modularity Always Worth It? - Glyn NormingtonIs OSGi Modularity Always Worth It? - Glyn Normington
Is OSGi Modularity Always Worth It? - Glyn Normingtonmfrancis
 
Building Next-Gen Web Applications with the Spring 3 Web Stack
Building Next-Gen Web Applications with the Spring 3 Web StackBuilding Next-Gen Web Applications with the Spring 3 Web Stack
Building Next-Gen Web Applications with the Spring 3 Web StackJeremy Grelle
 

Similar to Development with Vert.x: an event-driven application framework for the JVM (20)

MvvmCross Introduction
MvvmCross IntroductionMvvmCross Introduction
MvvmCross Introduction
 
MvvmCross Seminar
MvvmCross SeminarMvvmCross Seminar
MvvmCross Seminar
 
Node.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNode.js In The Enterprise - A Primer
Node.js In The Enterprise - A Primer
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
Demystifying Containerization Principles for Data Scientists
Demystifying Containerization Principles for Data ScientistsDemystifying Containerization Principles for Data Scientists
Demystifying Containerization Principles for Data Scientists
 
Node js internal
Node js internalNode js internal
Node js internal
 
Introduction to node.js by jiban
Introduction to node.js by jibanIntroduction to node.js by jiban
Introduction to node.js by jiban
 
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
8 Node.js Frameworks Every Developer Should Know [UPDATED].pptx
 
Surrogate dependencies (in node js) v1.0
Surrogate dependencies  (in node js)  v1.0Surrogate dependencies  (in node js)  v1.0
Surrogate dependencies (in node js) v1.0
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel Aviv
 
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - RedmondBuilding APIs with NodeJS on Microsoft Azure Websites - Redmond
Building APIs with NodeJS on Microsoft Azure Websites - Redmond
 
Quick introduction to nodeJs
Quick introduction to nodeJsQuick introduction to nodeJs
Quick introduction to nodeJs
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
 
Top 10 frameworks of node js
Top 10 frameworks of node jsTop 10 frameworks of node js
Top 10 frameworks of node js
 
Apereo OAE - Architectural overview
Apereo OAE - Architectural overviewApereo OAE - Architectural overview
Apereo OAE - Architectural overview
 
Dockers and kubernetes
Dockers and kubernetesDockers and kubernetes
Dockers and kubernetes
 
An introduction to Node.js application development
An introduction to Node.js application developmentAn introduction to Node.js application development
An introduction to Node.js application development
 
Node js
Node jsNode js
Node js
 
Is OSGi Modularity Always Worth It? - Glyn Normington
Is OSGi Modularity Always Worth It? - Glyn NormingtonIs OSGi Modularity Always Worth It? - Glyn Normington
Is OSGi Modularity Always Worth It? - Glyn Normington
 
Building Next-Gen Web Applications with the Spring 3 Web Stack
Building Next-Gen Web Applications with the Spring 3 Web StackBuilding Next-Gen Web Applications with the Spring 3 Web Stack
Building Next-Gen Web Applications with the Spring 3 Web Stack
 

Recently uploaded

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Recently uploaded (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Development with Vert.x: an event-driven application framework for the JVM

  • 1. Development with Vert.x: an event-driven application framework for the JVM David Wu @wuman blog.wu-man.com Taiwan Java User Group (2013/06/29) 1Monday, July 1, 13
  • 4. What most people will tell you about Vert.x • A general-purpose application framework running on JVM • Performant: asynchronous APIs, event-driven, non-blocking, etc. • Highly scalable but also easy to implement concurrency • Polyglot: intermix Java, JS, Ruby, Groovy, Python, etc. 4Monday, July 1, 13
  • 5. What I think about Vert.x • All-in-one framework that allows you to focus on your application rather than fiddling with different technologies • Business friendly Apache License 2.0 • Loose coupling modules that interoperate in a system 5Monday, July 1, 13
  • 6. Background on the C10K Problem 6Monday, July 1, 13
  • 7. Shift from Threading to Asynchronous the story of switching from Apache to Node.js 7Monday, July 1, 13
  • 8. The inevitable comparison to Node.js • A single event loop serving a high volume of connections via an asynchronous programming model • Most of the real work are done in a pool of background threads 8Monday, July 1, 13
  • 9. Asynchronous Programming Model vertx.createHttpServer().requestHandler( new Handler<HttpServerRequest>() { public void handle(HttpServerRequest request) { log.info("A request has arrived on the server!"); request.response().end(); } } ).listen(8080, "localhost"); 9Monday, July 1, 13
  • 10. But there are 3 problems with Node.js 10Monday, July 1, 13
  • 11. Problems with Node.js • Well, it’s not Java (and this is a Java User Group) • Does not easily scale both vertically and horizontally • Single event loop fails when you have CPU- intensive tasks or 3rd-party blocking APIs 11Monday, July 1, 13
  • 12. Vert.x to the rescue • Use all available cores on a single machine • Horizontally scale out to multiple boxes • Allow blocking calls to NOT run on an event loop 12Monday, July 1, 13
  • 13. Introduction to Vert.x instance and Verticles Verticle Verticle WorkerVerticle WorkerVerticle Vert.x instance 13Monday, July 1, 13
  • 14. Verticles are extremely isolated • Verticles are isolated with separate class loaders • A verticle never gets executed by more than one thread concurrently • No race conditions, no deadlocks. You write your code as single threaded. 14Monday, July 1, 13
  • 16. Message Passing via the Event Bus Verticle Verticle Worker Verticle Worker Verticle Vert.x instance 16Monday, July 1, 13
  • 17. Very Powerful Event Bus Verticle Verticle WorkerVerticle Verticle Verticle WorkerVerticle 17Monday, July 1, 13
  • 18. Registering a Message Handler EventBus eb = vertx.eventBus(); Handler<Message> myHandler = new Handler<Message>() { public void handle(Message message) { System.out.println("I received a message " + message.body); } }; eb.registerHandler("test.address", myHandler); 18Monday, July 1, 13
  • 19. Message Types • Primitives and their boxed types • String • org.vertx.java.core.json.JsonObject • org.vertx.java.core.json.JsonArray • org.vertx.java.core.buffer.Buffer 19Monday, July 1, 13
  • 20. Pub/Sub Model eb.publish("test.address", "hello world"); 20Monday, July 1, 13
  • 21. Point-to-Point Model eb.send("test.address", "This is a message", new Handler<Message<String>>() { public void handle(Message<String> message) { System.out.println("I received a reply " + message.body); } }); EventBus eb = vertx.eventBus(); Handler<Message> myHandler = new Handler<Message>() { public void handle(Message message) { System.out.println("I received a message " + message.body); message.reply("This is a reply"); } }; eb.registerHandler("test.address", myHandler); 21Monday, July 1, 13
  • 22. Shared Maps and Sets ConcurrentMap<String, Integer> map = vertx.sharedData().getMap("demo.mymap"); map.put("some-key", 123); Set<String> set = vertx.sharedData().getSet("demo.myset"); set.add("some-value"); 22Monday, July 1, 13
  • 24. Writing Verticles import org.vertx.java.core.Handler; import org.vertx.java.core.net.NetSocket; import org.vertx.java.core.streams.Pump; import org.vertx.java.platform.Verticle; public class Server extends Verticle { public void start() { vertx.createNetServer().connectHandler(new Handler<NetSocket>() { public void handle(final NetSocket socket) { Pump.createPump(socket, socket).start(); } }).listen(1234); } } vertx run Server.java 24Monday, July 1, 13
  • 25. Deploying Verticles programmatically // For example - deploy some other verticle container.deployVerticle("foo.js", new AsyncResultHandler<String>() { public void handle(AsyncResult<String> deployResult) { if (deployResult.succeeded()) { System.out.println(“Yay!”); } else { System.out.println(“Error: “ + deployResult.cause()); } } }); 25Monday, July 1, 13
  • 26. Modules • Package verticles into re-usable modules • Simply a zip file containing module definition, code, and resources • Very similar to the module system in Node.js • Modules can be “zip” artifacts released in Maven Central • Vert.x web site maintains a listing of Vert.x modules 26Monday, July 1, 13
  • 27. Example Modules • JDBC, Redis, MongoDB Persistors • AMQP • Mailer • Persistent work queue • Authentication Manager • Session Manager • Web framework • Language implementations 27Monday, July 1, 13
  • 29. Core APIs • TCP/SSL servers and clients • HTTP/HTTPS servers and clients • WebSockets servers and clients • SockJS • EventBus • Shared Maps and Sets • Buffers • Flow control • Timers • Files • Configuration 29Monday, July 1, 13
  • 30. Container API • Deploying and undeploying verticles • Deploying and undeploying modules • Logging • Retrieve verticle configuration 30Monday, July 1, 13
  • 31. Easy development • Gradle template • Maven archetype and plugin • IDE debugging and testing 31Monday, July 1, 13
  • 32. What is it good for? 32Monday, July 1, 13
  • 33. Applications • Realtime analytics dashboard • Big data queries and task coordination • Polyglot integration 33Monday, July 1, 13
  • 35. Real life caveats • Content assist in IDEs don’t work for busmod APIs • You often find yourself tracing errors in the busmods, which can be difficult because the stack trace stops at message passing • People writing in other languages often get frustrated by not being able to use native extensions that they are already used to. • Hell of anonymous inner class callbacks and no good Java flow control libraries • Java7 only. Doesn’t work on Android. 35Monday, July 1, 13
  • 38. “Using a bleeding-edge framework is exciting at first. Not so much afterwards.” David Wu 37Monday, July 1, 13
  • 41. Q & A 40Monday, July 1, 13