Your SlideShare is downloading. ×
  • Like
JUDCon Brazil 2013 - Vert.x an introduction
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

JUDCon Brazil 2013 - Vert.x an introduction

  • 1,315 views
Published

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,315
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
20
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Vert.x, an IntroductionClebert SuconicSamuel Tauil
  • 2. Project Info• 100% open source• Docs and web-site licensed under Creative Commons• Code licensed under ASL 2.0• Top 10 Java projects on githubhttps://github.com/languages/Java/most_watched
  • 3. What is Vert.x?• General purpose application platform• VMware sponsored OS project• Runs on the JVM• Provides primarily asynchronous APIs• Popular for modern web applications• Solves similar problems as Node.js, Akka, Play…
  • 4. vert.xFramework to writepolyglot,highly concurrent apps
  • 5. vert.xFramework to writepolyglot,highly concurrent apps
  • 6. Javascriptload(vertx.js)vertx.createHttpServer().requestHandler(function(req) {req.response.end("<html><body><h1>Hello from vert.x!</h1></body></html>");}).listen(8080, localhost);
  • 7. Javascriptload(vertx.js)vertx.createHttpServer().requestHandler(function(req) {req.response.end("<html><body><h1>Hello from vert.x!</h1></body></html>");}).listen(8080, localhost);$ vertx run example.js –instances 32
  • 8. Groovyvertx.createHttpServer().requestHandler { req ->req.response.end "<html><body><h1>Hello from vert.x!</h1></body></html>"}.listen(8080, "localhost")$ vertx run example.groovy
  • 9. Pythonserver = vertx.create_http_server()@server.request_handlerdef handle(req):req.response.end("<html><body><h1>Hello from vert.x!</h1></body></html>")server.listen(8080)$ vertx run example.py
  • 10. Rubyrequire "vertx"include VertxHttpServer.new.request_handler do |req|req.response.end("<html><body><h1>Hello from vert.x!</h1></body></html>")end.listen(8080)$ vertx run example.rb
  • 11. Javaimport org.vertx.java.core.Handler;import org.vertx.java.core.http.HttpServerRequest;import org.vertx.java.platform.Verticle;public class ServerExample extends Verticle {public void start() {vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {public void handle(HttpServerRequest req) {req.response().headers().put("Content-Type", "text/html; charset=UTF-8");req.response().end("<html><body><h1>Hello from vert.x!</h1></body></html>");}}).listen(8080);}}$ vertx run ServerExample.java
  • 12. vert.xFramework to writepolyglot,highly concurrent apps
  • 13. Core Concepts• Verticle• vert.x instance• Event bus
  • 14. Verticles runs insidea vert.x instance.A single vert.x instanceruns inside its ownJVM instance.
  • 15. Verticles• Are the execution units of vert.x• Mult-language by modules• Application is composed by many verticles• Verticles communicate by message passing• Verticles provide isolation
  • 16. Event Bus• The nervous system of Vert.x• Verticles communicate using the event bus.• Ultra simple API.• Point to point. Publish/Subscribe.Request/Response.• Pass simple strings, numbers or otherprimitive types.• JSON messages are preferred for structureddata.
  • 17. Event Bus• Allows verticles to talk each other• Works cross language• Works across the cluster• Spans from server to client side
  • 18. Event Bus• Register Handlers• Unregister Handlers• Addresses• Messages (transient)
  • 19. load(vertx.js)var eb = vertx.eventBus;var address = example.addressvar handler = function(message) {stdout.println(Received message + message)}eb.registerHandler(address, handler);function vertxStop() {eb.unregisterHandler(address, handler);}Handler
  • 20. load(vertx.js)var eb = vertx.eventBus;var address = example.address’vertx.setPeriodic(2000, sendMessage)var count = 0function sendMessage() {var msg = "some-message-" + count++;eb.send(address, msg);stdout.println("sent message " + msg)}Sender
  • 21. Publish Subscribeeb.publish(‘example.address’, ‘hello world’);
  • 22. Point to pointeb.send(‘example.address’, ‘hello world’);
  • 23. Scaling• Scale by creating more Verticle instances• Use message passing to communicate.• Sounds like the Actor Model? Its similar• For TCP and HTTP servers Vert.x willautomatically load-balance
  • 24. SockJS• Handles the communication between thebrowser and the server.• Provides a websocket-like API in client-side JS• Works when websockets not available• More info at http://sockjs.org
  • 25. InternalsNetty for network IOJRuby for the Ruby engineGroovyMozilla Rhino for JSJython for Python supportHazelcast for clustering
  • 26. Future• Scala and Clojure support• Management, including GUI console• Developer experience - IDE integration,testing• Direct-style API using continuations?
  • 27. http://vertx.io/
  • 28. Questions?Thankscsuconic@redhat.comsamuel@redhat.com