Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red...
-
Upload
jaxlondonconference -
Category
Technology
-
view
1.501 -
download
1
description
Transcript of Introducing Vert.x 2.0 - Taking polyglot application development to the next level - Tim Fox (Red...
Vert.x 2 Taking polyglot application
development to the next level
Tim FoxVert.x Project Lead
Red Hattwitter:@timfox
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...
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
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
Polyglot
Fully supported:
Beta level support:
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!
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
Verticle
■ Execution unit of Vert.x
■ Single threaded – less scope for race conditions
■ Verticles communicate by message passing
■ Sounds like the Actor Model?
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
Performance demo
■ Run the perf server and client demo
■
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
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
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
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
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
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
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
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
It's all about the modules
■ MongoDB
■ Redis
■ MySQL/PostgreSQL
■ SMTP
■ JDBC
■ Jersey
■ Promises
■ Guice
■ Spring
■ Vertigo
■ Metrics
■ Yoke
■ Stomp
■ BSON
■ work-queue
■ NoDyn
■ GCM
■ SocketIO
■ Sessions
■ Via
■ RxJava
Fat jars
■ Build module into self contained "fat" executable jar
■ Convenient for devops
■ Fairly small overhead
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
High Availability
■ Automatic failover of deployed modules
■ Nodes can be grouped
■ Network partition detection with quora
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
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
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
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
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
Q&Ahttp://vertx.io/