Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red...

28
Vert.x 2 Taking polyglot application development to the next level Tim Fox Vert.x Project Lead Red Hat twitter:@timfox

description

Presented at JAX London 2013 Vert.x is a lightweight, high performance, application platform for the JVM that's designed for modern mobile, web, and enterprise applications. The recent Vert.x 2.0 release marks a coming of age for Vert.x, as it progresses to a fully independent project. We'll dive into the Vert.x 2.0 release and show how the powerful new module system enables a Vert.x ecosystem by allowing modules to be re-used via Maven and Bintray repositories. You'll also learn about how better build tool and IDE integration makes developing applications with Vert.x a breeze.

Transcript of Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red...

Page 1: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Vert.x 2 Taking polyglot application

development to the next level

Tim FoxVert.x Project Lead

Red Hattwitter:@timfox

Page 2: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Bio

■ Employed By Red Hat to lead the Vert.x project

■ Some projects I've been involved with: Vert.x (creator), RabbitMQ, HornetQ (creator), JBoss AS, Mobicents...

Page 3: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Project Info

■ Independent Community Project

■ The main project is an Eclipse Foundation project

■ All code is on GitHub

■ 100% open source (ASL 2.0 + Creative Commons)

■ One of the most popular Java projects on GitHub

Page 4: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Vert.x Overview

■ Lightweight reactive application platform

■ Polyglot

■ High performance

■ Superficially similar to Node.js – but not a clone!

■ Asynchronous APIs

■ Simple but not simplistic

■ Embeddable

Page 5: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Polyglot

Fully supported:

Beta level support:

Page 6: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Core Asychronous APIs

■ TCP/SSL clients and servers

■ HTTP/HTTPS clients and servers

■ Websockets

■ SockJS

■ File system

■ Event bus

■ DNS (new)

■ UDP (new)

■ Core is small and static – most new functionality in modules

■ Don't call us, we'll call you!

Page 7: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Why Asynchronous?

■ Modern servers need to handle many connections – web servers, websockets, IoT

■ OS threads are still a precious resource

■ Need to service many connections with small number of threads

■ Blocked OS threads means they can't do other work

Page 8: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Verticle

■ Execution unit of Vert.x

■ Single threaded – less scope for race conditions

■ Verticles communicate by message passing

■ Sounds like the Actor Model?

Page 9: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Simple web server demo

■ Vertx run webserver.js

■ Show code in gedit

■ Explain about raw verticles

■ Also show WebServer.java

■ Run it too

■ Talk about Java source verticles

Page 10: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Performance demo

■ Run the perf server and client demo

Page 11: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Event Bus

■ The nervous system of Vert.x

■ Verticles send messages over the event bus

■ Point to point. Publish/Subscribe. Request/Response

■ Pass strings, buffers, primitive types or JSON

■ JSON messages are preferred for structured data

Page 12: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Clustered Event Bus

■ Lightweight peer-to-peer messaging system

■ Connects multiple Vert.x JVM instances

■ Applications are loosely coupled components distributed across your network

■ No monolithic “application server”

■ Cluster manager is pluggable, default is Hazelcast

■ Cluster manager used for group management, not transport

Page 13: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Event bus in the Browser

■ Event bus extends to client side JavaScript too

■ Uses the same API on the client

■ Powerful distributed event space spanning both client and server nodes

■ Ideal for modern “real-time” web applications

Page 14: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Clustered event bus demo

■ receiver.js and Sender.java

■ Show code

■ Show messages being received

■ Start bridge (need 3rd console for this)

■ Show browser receiving messages too

Page 15: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Modules

■ Modules encapsulate code and resources

■ One or more modules per application

■ Must include a mod.json descriptor file

■ Can be runnable or non runnable

■ Module class-loaders provide isolation

Page 16: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Explore module demo

■ Look at a simple runnable module on disk

■ Show the mod.json

■ It's a simple TCP echo server

■ Run it with vertx runmod

Page 17: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

An ecosystem of modules

■ Sharing modules encourages reuse

■ Modules can be pushed to any Maven or Bintray repository

■ Vert.x can resolve modules at build time or run time

■ Want to encourage an ecosystem of modules

■ Register your modules in the registry

Page 18: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Module resolve demo

■ Delete the module that we explored in the last example

■ Do a vertx runmod on it again

■ Explore the mods directory again

Page 19: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

It's all about the modules

■ MongoDB

■ Redis

■ MySQL/PostgreSQL

■ SMTP

■ JDBC

■ Jersey

■ Promises

■ Guice

■ Spring

■ Vertigo

■ Metrics

■ Facebook

■ Yoke

■ Stomp

■ BSON

■ work-queue

■ NoDyn

■ GCM

■ SocketIO

■ Sessions

■ Via

■ RxJava

Page 20: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Fat jars

■ Build module into self contained "fat" executable jar

■ Convenient for devops

■ Fairly small overhead

Page 21: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Fat jar demo

■ Do vertx fatjar of the module from before

■ Take a look at the jar, look at its size

■ Execute it

■ Maybe unzip it and look inside

Page 22: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

High Availability

■ Automatic failover of deployed modules

■ Nodes can be grouped

■ Network partition detection with quora

Page 23: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

HA demo

■ Keep bridge running from before

■ Use one Scala sender.scala module and one Groovy sender module

■ Start them both with -ha flag

■ Look at browser

■ Kill one ps aux | grep Sender.java

■ Look at browser again

■ Start an empty vertx

■ Fail it back

Page 24: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Developing with Vert.x

■ Vert.x is IDE and build system agnostic

■ Can just a text editor if you like

■ Maven archetype

■ Gradle template

■ Debug and test in IDE

■ Module auto-redeploy during development

Page 25: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Auto-redeploy demo

■ Show Maven project in eclipse

■ Project is module with sender.rb in it

■ mvn vertx:runModEclipse

■ Look at browser

■ Make change

■ Look at browser again

Page 26: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Summary■ Write apps as set of loosely coupled components that live anywhere

where you want

■ Polyglot – use the language(s) you want

■ Simple concurrency – wave goodbye to most race conditions

■ Module system – empower the community

■ High availability

■ Ease of development

We believe Vert.x is the platform for the new generation of reactive polyglot web and enterprise applications

Page 27: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Get involved!

■ Loads more to do

■ Active and growing community

■ Github: https://github.com/vert-x/vert.x

■ Google group: vertx

■ IRC channel: #vertx on freenode.net

Page 28: Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red Hat)

Q&Ahttp://vertx.io/