Upload
normation
View
1.365
Download
4
Tags:
Embed Size (px)
DESCRIPTION
Some slides demonstrating what ZeroMQ is and how it can be used from Scala, with the native Scala-ZeroMQ binding or the Akka-zeromq module. Acually, code examples are on a GitHub repository here: https://github.com/fanf/scala_zeromq. The presentation was given on 2013-08-21 at the Paris Scala User Group.
Citation preview
Normation – CC-BY-SAnormation.com 1
Scala and ZeroMQ Events beyond the JVM
Scala and ZeroMQ Events beyond the JVM
François ARMANDDirecteur R&D - [email protected]
Normation – CC-BY-SAnormation.com 2
Qui suis-je ?
Scalaist since...
● mid-2006 for personnal projects
● Rudder : full time Scala since mid-2009
● Projet LaFoSec : sécurité des langages fonctionnels (in French)
– Scala from the point of view of IT security
– 2010 paper for the Agence Nationnal de la Sécurité de SI (ANSSI)
– http://www.ssi.gouv.fr/fr/anssi/publications/publications-scientifiques/autres-publications/lafosec-securite-et-langages-fonctionnels.html
Co-founderLead-architect
[email protected] @fanf42
François ARMAND
Normation – CC-BY-SAnormation.com 3
De quoi va-t-on parler ?
● ZeroMQ presentation
● Integration with Scala
● Code, code, code, code...
Normation – CC-BY-SAnormation.com 4
Scala and ZeroMQ Events beyond the JVM
ZeroMQ : Ounce upon a time,
the quest for the GrailMOM
François ARMANDDirecteur R&D - [email protected]
Normation – CC-BY-SAnormation.com 5
MOM : Grail of IT integration
● Message Oriented Middleware (and Architecture)
● Grails of IT integration
Normation – CC-BY-SAnormation.com 6
ZeroMQ : history and presentation
● In the '90s, messaging middlewares :
● Banks / trading places:
● Need for hight speed Events interchange queues
● 2003 : Advanced Message Queuing Protocol
« Toward a commodity (message oriented) middleware »
– Message orientation
– Queuing
– Routing (including point-to-point and publish-and-subscribe),
– Reliability
– Security.
Normation – CC-BY-SAnormation.com 7
From AMQP to Nano
● AMQP version 1.0 : October 2011 (!!!)
● AMQP : Oasis Standard : October 2012
● RabbitMQ still refuses to implements v1.0
● 2004: iMatix, initiator of the project resigned and starts ZeroMQ
Hi Folks,Here at iMatix we've participated since 2004 in AMQP but today we'vedecided to end that. We're going to be killing support for OpenAMQand migrating our users to ZeroMQ, which is simpler, faster, and inour view a better bet for our users.We have serious, long lived, and unaddressed concerns with the AMQPdevelopment process and today our worst predictions seem to have cometrue: AMQP is a game for large firms, and ignores the needs of themajority of users and vendors. For us, that means failure.
● 2012: iMatix, iniator of the ZeroMQ project and starts Crossroads.io
● But it's dead because...
● 2013: Martin Sustrik, original author of ZeroMQ and Crossroads.io, leaves to build Nano...
Normation – CC-BY-SAnormation.com 8
From AMQP to Nano
● AMQP version 1.0 : October 2011 (!!!)
● AMQP : Oasis Standard : October 2012
● RabbitMQ still refuses to implements v1.0
● 2004 : iMatix, initiator of the project resigned and starts ZeroMQ
Hi Folks,Here at iMatix we've participated since 2004 in AMQP but today we'vedecided to end that. We're going to be killing support for OpenAMQand migrating our users to ZeroMQ, which is simpler, faster, and inour view a better bet for our users.We have serious, long lived, and unaddressed concerns with the AMQPdevelopment process and today our worst predictions seem to have cometrue: AMQP is a game for large firms, and ignores the needs of themajority of users and vendors. For us, that means failure.
● 2012 : iMatix, iniator of the ZeroMQ project and starts crossroads.io
● But that dead because...
● 2013 : Martin Sustrik, original author of ZeroMQ and Crossroads.io, leaves to build Nano...
Normation – CC-BY-SAnormation.com 9
ZeroMQ
Ø Not a MOM (no broker, no queues, etc)
Ø Socket library that acts as a concurrency framework.
Ø Carries messages across inproc, IPC, TCP, and multicast.
Ø Connect N-to-N via fanout, pubsub, pipeline, request-reply.
Ø Asynch I/O for scalable multicore message-passing apps.
Ø 40+ languages including C, C++, Java, .NET, Python.
Ø http://zguide.zeromq.org/
Normation – CC-BY-SAnormation.com 10
Scala and ZeroMQ Events beyond the JVM
Sockets for this millenium
François ARMANDDirecteur R&D - [email protected]
Normation – CC-BY-SAnormation.com 11
ZeroMQ sockets
● « It's sockets on steroids. It's like mailboxes with routing. It's fast! »
● ZeroMQ patterns (and sockets) :
● Request-reply
– Connects a set of clients to a set of services.
– This is a remote procedure call and task distribution pattern.
● Pub-sub
– Connects a set of publishers to a set of subscribers.
– This is a data distribution pattern.
● Pipelines
– Connects nodes in a fan-out/fan-in pattern that can have multiple steps and loops.
– This is a parallel task distribution and collection pattern.
● Exclusive pair
– Connects two sockets exclusively.
– This is a pattern for connecting two threads in a process
– Not to be confused with "normal" pairs of sockets.
Normation – CC-BY-SAnormation.com 12
ZeroMQ sockets
● « It's sockets on steroids. It's like mailboxes with routing. It's fast! »
● ZeroMQ patterns (and sockets) :
● Request-reply
– Connects a set of clients to a set of services.
– This is a remote procedure call and task distribution pattern.
● Pub-sub
– Connects a set of publishers to a set of subscribers.
– This is a data distribution pattern.
● Pipelines
– Connects nodes in a fan-out/fan-in pattern that can have multiple steps and loops.
– This is a parallel task distribution and collection pattern.
● Exclusive pair
– Connects two sockets exclusively.
– This is a pattern for connecting two threads in a process
– Not to be confused with "normal" pairs of sockets.
Normation – CC-BY-SAnormation.com 13
Scala and ZeroMQ Events beyond the JVM
Scala and ZeroMQ
François ARMANDDirecteur R&D - [email protected]
Normation – CC-BY-SAnormation.com 14
Scala and ZeroMQ
● C-Scala native binding
● http://zeromq.org/bindings:scala-binding
● Uses JNA
● Only supports libzmq v2.1
● Akka integration
● Akka-zeromq module
● http://doc.akka.io/docs/akka/2.2.0/scala/zeromq.html
● Documentation and example are sparses
Normation – CC-BY-SAnormation.com 15
Scala and ZeroMQ - remarks
● I'm still believing AKKA is Scala killer-app
● It went a looooooooooooooooooong way since my last try 3 years ago
● I'm believing ZeroMQ will be in all IT infrastructures soon
● I'm still HATING AKKA untyped model
● Next time, I'm going to try Typed Actor / Channel
Normation – CC-BY-SAnormation.com 16
Scala and ZeroMQ Events beyond the JVM
Pub/Sub. Young people these days
have got it easy
François ARMANDDirecteur R&D - [email protected]
Normation – CC-BY-SAnormation.com 17
ZeroMQ sockets : Pub / Sub
● Publish / Subscribes sockets
● It's just work, nothing to add
Normation – CC-BY-SAnormation.com 18
ZeroMQ sockets : Pub / Sub
Code !
https://github.com/fanf/scala_zeromq/tree/master/src/main/scala/psug/zeromq/pubsub
Normation – CC-BY-SAnormation.com 19
Scala and ZeroMQ Events beyond the JVM
Req/Rep. Because waiting for answer
is hard.
François ARMANDDirecteur R&D - [email protected]
Normation – CC-BY-SAnormation.com 20
ZeroMQ sockets : Req / Rep
● Request / Reply sockets
● Statefull request ↔ reply cycles
Normation – CC-BY-SAnormation.com 21
ZeroMQ sockets : Req / Rep
Code !
https://github.com/fanf/scala_zeromq/tree/master/src/main/scala/psug/zeromq/reqrep
Normation – CC-BY-SAnormation.com 22
Scala and ZeroMQ Events beyond the JVM
Questions ?
François ARMANDDirecteur R&D - [email protected]