Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVM

download Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVM

If you can't read please download the document

Transcript of Scala.io 2013 - Scala and ZeroMQ: Events beyond the JVM

Scala and ZeroMQ
Events beyond the JVM

Franois ARMANDDirecteur R&D - [email protected]

Speaker

[email protected]

Franois @fanf42 ARMAND

Scala since...

PSUG!!!

(for personal projects)

Co-founder

Lead-dev

Projet LaFoSecScurit des langages fonctionnels(Scala from the point of view of IT security)French paper for the Agence Nationnal de la Scurit de SI (ANSSI)

What's next?

ZeroMQpresentation

Integration with Scala

Code, code, code, code...

ZeroMQ:
Ounce upon a time,
the quest for the GrailMOM

MOM: Grail of IT integration

Message Oriented Middleware (and Architecture)Grails of IT integration

ZeroMQ: history and presentation

In the '90s, messagingmiddlewares:

Banks/ trading places: Need for hight speed Events interchange queues and EAI

2003: Advanced Message Queuing ProtocolToward a commodity (message oriented) middlewareMessage orientation

Queuing

Routing (including point-to-point and publish-and-subscribe),

Reliability

Security.

From AMQPto Nano

AMQP version 1.0: October 2011 (!!!)

AMQP: Oasis Standard: October 2012RabbitMQ still refuses to implements v1.0

2004: iMatix, initiator of the project resignedand 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, founder of the ZeroMQ project and starts Crossroads.ioBut it's dead because...

2013: Martin Sustrik, original author of ZeroMQ and Crossroads.io, leaves to build Nano...

From AMQPto Nano

AMQP version 1.0: October 2011 (!!!)

AMQP: Oasis Standard: October 2012RabbitMQ still refuses to implements v1.0

2004: iMatix, initiator of the project resignedand 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, founder of the ZeroMQ project and starts Crossroads.ioBut it's dead because...

2013: Martin Sustrik, original author of ZeroMQ and Crossroads.io, leaves to build Nano...

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/

Sockets for this millenium

ZeroMQ sockets

It's sockets on steroids. It's like mailboxes with routing. It's fast!

ZeroMQ patterns (and sockets):Request-ReplyConnects a set of clients to a set of services.

This is a remote procedure call and task distribution pattern.

Pub-SubConnects a set of publishers to a set of subscribers.

This is a data distribution pattern.

PipelinesConnects 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 pairConnects two sockets exclusively.

This is a pattern for connecting two threads in a process

Not to be confused with "normal" pairs of sockets.

ZeroMQ sockets

It's sockets on steroids. It's like mailboxes with routing. It's fast!

ZeroMQ patterns (and sockets):Request-ReplyConnects a set of clients to a set of services.

This is a remote procedure call and task distribution pattern.

Pub-SubConnects a set of publishers to a set of subscribers.

This is a data distribution pattern.

PipelinesConnects 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 pairConnects two sockets exclusively.

This is a pattern for connecting two threads in a process

Not to be confused with "normal" pairs of sockets.

Scala and ZeroMQ

Scala and ZeroMQ

C-Scala native bindinghttp://zeromq.org/bindings:scala-binding

Uses JNA

Only supports libzmq v2.1

Akka integrationAkka-zeromq module

http://doc.akka.io/docs/akka/2.2.0/scala/zeromq.html

Documentation and examples are sparse

Scala and ZeroMQ - remarks

I'm still believing AKKA is Scala killer-app(if such a thing exists / is needed)

It went a looooooooong way since my last try 3 years ago

I'm believing ZeroMQ (or a successor) will be in all IT infrastructures soon

I'm still HATING AKKA untyped modelI want to be able to define SYSTEMS with BOUNDARIES

Next time, I'm going to try Typed Actor / Channel

Or perhaps Clojure core.typed + core.async

Pub/Sub.

Young people these days have got it easy

ZeroMQ sockets: Pub / Sub

Publish / Subscribes socketsIt's just work, nothing to add

Raw Pub/Sub code

Raw Pub/Sub code

AKKA Pub/Sub

Scala (Server)ZMQ SocketActor

Client (Akka)

ZMQ SocketActor

AKKA Pub/Sub code

AKKA Pub/Sub code

Req/Rep

Because waiting for answer is hard.

ZeroMQ sockets: Req / Rep

Request / Reply socketsStatefull request reply cycles

Raw Req / Rep code

Raw Req / Rep code

Ask pattern with ZeroMQ

AKKA "ASK" Pattern build on top of ZeroMQIntegrate non-JVM elements in your AKKA system

Actor ZmqClientZMQ Socket(Rep)

ServerZMQ SocketActor (Req)

ActorMessageCollector

1/ ASK

2/ Send message to ZMQ socket

4/ Server get message

5/ Server response

7/ Get response by ZMQ socket

8/ Answer

Outside the JVMInto the wild

6/ Send response to ZMQ socket

3/ Get query by ZMQ socket

Ask pattern with ZeroMQ

81

Ask pattern with ZeroMQ

4

5

Ask pattern with ZeroMQ

1782

Questions?

hello

Normation CC-BY-SAnormation.com

2013-10-{24,25}