An Introduction to the Vert.x framework

Post on 10-May-2015

1,491 views 4 download

Tags:

description

Vert.x is a new JVM based application framework with an event driven, asynchronous programming model. With APIs available in Java, JavaScript, Ruby, Python and Groovy, developers are given complete freedom to implement their application in the language of their choice. Starting with the core Vert.x concepts, this presentation will walk attendees through the components of a simple vert.x based application. Through this process, attendees will gain an understanding of how Vert.x: - provides for a way to use several different languages in the same application - takes advantage of JVMs excellent multi-core capabilities - uses a module-based framework for packaging and hot-deployment - communicates with other processes via a distributed event bus - exposes an asynchronous programming model with very simple concurrency With this presentation, viewers should gain a deep-enough understanding of Vert.x to be able to evaluate the platform for their own projects.

transcript

OSCONAn Introduction to the

Vert.x framework

Wednesday, July 24, 13

Hi Folks! I’m Nate @zznate http://github.com/zznate

Wednesday, July 24, 13

So what is Vert.x?

Wednesday, July 24, 13

“...lightweight high-performance application platform for the JVM...”

Wednesday, July 24, 13

“...for the JVM”

Wednesday, July 24, 13

The JVM- mature concurrency model- very stable- heterogeneous

Wednesday, July 24, 13

But most importantly...Polyglot support!

Wednesday, July 24, 13

You can do a lot in 40 minutes...

Wednesday, July 24, 13

http://vertx.io(scroll down)

To follow along, see: https://github.com/vert-x/vertx-examples 

Wednesday, July 24, 13

“Web apps”

Wednesday, July 24, 13

Wednesday, July 24, 13

Wednesday, July 24, 13

"We need to make configuration as easy as possible so expensive tools are not needed." 

Wednesday, July 24, 13

Said no enterpirse software company ever.

Wednesday, July 24, 13

JDBC Module Config:{ address : "com.bloidonia.jdbcpersistor" driver : "org.hsqldb.jdbcDriver", url : "jdbc:hsqldb:mem:test", username : "someuser", password : "somepass",}

https://github.com/timyates/mod-jdbc-persistor

Wednesday, July 24, 13

“New [Java | jvm-language] Framework!!”

Wednesday, July 24, 13

But Vert.x was different.

Wednesday, July 24, 13

...for the JVM

Wednesday, July 24, 13

Mature concurrency model- vert.x is based on the Reactor pattern

http://en.wikipedia.org/wiki/Reactor_pattern

Wednesday, July 24, 13

Platform Stability- HTTP, HTTPS, TCP, SSL- clients and servers- All netty 4.0 based

http://netty.io/

Wednesday, July 24, 13

Homogenous- file system API- data-driven event bus

Wednesday, July 24, 13

Polyglot- Container modules- currently supports: JavaScript, Ruby, Python, Groovy, Scala,

Wednesday, July 24, 13

Scalability Modularity Developer-focused

Wednesday, July 24, 13

Scalability

Wednesday, July 24, 13

Event Bus- simple, distributed peer-to-peer - pub/sub or point-to-point- local or distributed**- ‘data only’ with limited number of types

Wednesday, July 24, 13

Event Bus... but it’s a good idea to use JSON!

(completely language agnostic - we are building services and decoupling!)

Wednesday, July 24, 13

“local or distributed”

BONUS: EventBus can extend directly to the browser

http://vertx.io/core_manual_java.html#sockjs-eventbus-bridge

Wednesday, July 24, 13

Modularity

Wednesday, July 24, 13

{ address : "com.bloidonia.jdbcpersistor" driver : "org.hsqldb.jdbcDriver", url : "jdbc:hsqldb:mem:test", username : "someuser", password : "somepass",}

Wednesday, July 24, 13

Module Benefits- encapsulation- distributability- dynamic- structured

Wednesday, July 24, 13

Encapsulation- classpath and dependency- classloader isolation(but multiple instances of the module will share classloaders)

Wednesday, July 24, 13

Distributabilitypushed to/loaded from:- file system (contained or shared)- maven central- bintray

http://vertx.io/mods_manual.html#how-vertx-locates-modules 

Wednesday, July 24, 13

Dynamic- automatically downloaded and installed- loaded/unloaded at runtime

Wednesday, July 24, 13

Structured- minimalistic descriptor syntax- sub-modules (can be thought of as "this module 'deploys' these modules" directive)

Wednesday, July 24, 13

Running a module and providing it’s configuration

Wednesday, July 24, 13

Modules and Concurency- Worker (blocking)- Event loop (non-blocking)

Wednesday, July 24, 13

Worker Modules- single or multi-threaded- useful for legacy APIs(ex. JDBC)

Wednesday, July 24, 13

Event Loop Modules- control number of instances- instance per core is ideal

Wednesday, July 24, 13

Modules (best for last...)

Wednesday, July 24, 13

Dog food-ing FTW:Language runtimes are all module based

Wednesday, July 24, 13

Developer friendly

Wednesday, July 24, 13

Polyglot (cont’d)

Wednesday, July 24, 13

JavaScript- Rhino - DynJS: invokeDynamic based implementation

http://dynjs.org/https://github.com/vert-x/mod-lang-dynjs

Wednesday, July 24, 13

Simple Programming Model- just don’t block the event loop!- reactor pattern- worker delegates

http://en.wikipedia.org/wiki/Reactor_patternhttp://vertx.io/core_manual_java.html#writing-verticles 

Wednesday, July 24, 13

Provides most common services- HTTP/HTTPS- TCP/SSL- SockJS- File system access (includes sendfile() wrappers)

Wednesday, July 24, 13

Build It: Maven- archetype integration- plug-in for launching/running

http://vertx.io/maven_dev.html 

Wednesday, July 24, 13

Build It: Gradle- template project to clone

http://vertx.io/gradle_dev.html 

Wednesday, July 24, 13

Test It!- JUnit integration utilities- Container and IDE integration(IntelliJ and Eclipse)

Wednesday, July 24, 13

Summary- General purpose application platform- Polyglot development- Asynchronous APIs

Wednesday, July 24, 13

Vert.x:Simple. Not Simplistic.

Wednesday, July 24, 13

Questions?

Wednesday, July 24, 13