Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Vertx
1. vert.x
Polyglot and Scalable Apps on the JVM
Álvaro Videla | VMware
Tuesday, October 9, 12
2. About Me
• Developer Advocate for Cloud Foundry
• Blog: http://videlalvaro.github.com/
• Twitter: @old_sound
Tuesday, October 9, 12
3. About Me
• Developer Advocate for Cloud Foundry
• Blog: http://videlalvaro.github.com/
• Twitter: @old_sound
• I created gifsockets™
Tuesday, October 9, 12
4. About Me
Co-authored
RabbitMQ in Action
http://bit.ly/rabbitmq
Tuesday, October 9, 12
27. Programming Model
• Event Based (similar to node.js)
• Event Handlers
• Small set of threads per vert.x instance
• Verticles are executed using the same
thread.
• Message Passing Communication
Tuesday, October 9, 12
36. Event Bus
• Allows Verticles to talk to each other
Tuesday, October 9, 12
37. Event Bus
• Allows Verticles to talk to each other
• Works cross language
Tuesday, October 9, 12
38. Event Bus
• Allows Verticles to talk to each other
• Works cross language
• Works across the cluster
Tuesday, October 9, 12
39. Event Bus
• Allows Verticles to talk to each other
• Works cross language
• Works across the cluster
• Spans from server to client side
Tuesday, October 9, 12
40. Event Bus - How
• Register Handlers
Tuesday, October 9, 12
41. Event Bus - How
• Register Handlers
• Unregister Handlers
Tuesday, October 9, 12
42. Event Bus - How
• Register Handlers
• Unregister Handlers
• Addresses
Tuesday, October 9, 12
43. Event Bus - How
• Register Handlers
• Unregister Handlers
• Addresses
• Messages (Transient)
Tuesday, October 9, 12
44. Register Handler
var eb = vertx.eventBus;
var myHandler = function(message)) {
log.info('I received a message ' + message);
}
eb.registerHandler('test.address', myHandler);
Tuesday, October 9, 12
45. Register Handler
var eb = vertx.eventBus;
var myHandler = function(message)) {
log.info('I received a message ' + message);
}
eb.registerHandler('test.address', myHandler);
eb.unregisterHandler('test.address', myHandler);
Tuesday, October 9, 12
46. Publish Subscribe
eb.publish('test.address', 'hello world');
Tuesday, October 9, 12
47. Point to Point
eb.send('test.address', 'hello world');
Tuesday, October 9, 12
48. RPC Server
var myHandler = function(message, replier) {
log.info('I received a message ' + message);
// Do some stuff
// Now reply to it
replier('This is a reply');
}
eb.registerHandler('test.address', myHandler);
Tuesday, October 9, 12
49. RPC Client
eb.send('test.address', 'This is a message', function(reply) {
log.info('I received a reply ' + reply);
});
Tuesday, October 9, 12
50. Shared Data
• Shared Maps
Tuesday, October 9, 12
51. Shared Data
• Shared Maps
• Shared Sets
Tuesday, October 9, 12
52. Shared Set Example
load('vertx.js')
var
conns
=
vertx.getSet('conns')
var
server
=
vertx.createNetServer().connectHandler(function(socket)
{
conns.add(socket.writeHandlerID)
socket.dataHandler(function(data)
{
var
aconns
=
conns.toArray();
for
(var
i
=
0;
i
<
aconns.length;
i++)
{
vertx.eventBus.send(aconns[i],
data)
}
});
socket.closedHandler(function()
{
conns.remove(
socket.writeHandlerID)
});
}).listen(1234)
Tuesday, October 9, 12
57. Internals
• Netty for network IO
• JRuby for the Ruby Engine
• Groovy
• Mozilla Rhino for JS
• Jython for Python support
• Hazelcast for clustering
Tuesday, October 9, 12