full-stack-bus
communicating ALL your applications
with RabbitMQ, postal.js and
javascript
javier arias losada @javier_arilos
imagine...
imagine your app needs growing (*)
it’s easy if you try
(*) by growing I mean functionality and/or performance and/or scalability
message bus
A message bus enables separate
applications to work together, but in
a decoupled fashion [1].
[1] http://bit.ly/1GI9W3B
message what?
Message bus technologies have been
used in backend for more than 20
years: IBM MQSeries in 1992 [2].
[2] http://bit.ly/1GIbV8f
did you say backend?
Nowadays we can use message bus in the
browser with the help of libraries
such as postal.js [3].
[3] http://bit.ly/1zozbq9
what’s full-stack-bus?
Yet Another Buzzword...
seriously, what’s full-stack-bus?
By uniting frontend and backend bus
technologies we can create
applications that work out together in
a decoupled fashion.
frontend => frontend
frontend => backend
backend => frontend
backend => backend
… but I already do that!!!!
frontend => frontend: eventEmitters, listeners, global variables...
frontend => backend: HTTP, Websockets...
backend => frontend: Websockets, Long-polling...
backend => backend : HTTP, sockets, shared Db...
Some of this are good
mechanisms.
...others are just
antipatterns…
Unifying approachs has
its own beauty.
why then, a message bus?
Message bus allow to offer decoupled
interfaces, based in Events/Messages.
No callbacks, no request-reply,
producers and consumers are decoupled.
Off-the-shelf communication patterns:
topics, queues, ...
is it for me?
Probably not. Message bus is not
everybody’s cup of tea.
If your platform is growing a lot in
terms of load and/or complexity then
it will help.
can we now start with the tech?
This is one possible way to
communicate all your applications.
postal.js
js
module
js
module
js
module
RabbitMQ
STOMP
over
Websokets
(SockJS)
μService μService μService
RabbitMQ
RabbitMQ is a Message Broker
implementing of the AMQP protocol. [4]
Fast and easy to use.
Open source :-)
Almost certainly it is supported in your language /
platform
Very advanced concepts:
● Messaging: exchanges, queues, routing, …
● Built-in clustering and replication
[4] http://www.rabbitmq.com
Postal.js
JS pub/sub library supporting some advanced
subscription features [5]
➔ in-memory message bus - very loosely inspired by AMQP
➔ runs in the browser, or on the server using node.js
➔ only pub/sub, no queues
➔ opensource (> 1K in github)
[5] https://github.com/postaljs/postal.js
javascript
Javascript is THE full-stack language: runs on
the client, server, databases and even on a
toaster [6]
[6] http://bit.ly/1uX9s44
In our sample game:
➔ node.js: μ-services
➔ angular: almost magical binding
.js
STOMP SockJS
[7] http://stomp.github.io/
[8] https://github.com/sockjs
[9] http://www.rabbitmq.com/web-stomp.html
STOMP Simple Text
Orientated Messaging
Protocol [7].
STOMP clients communicate
with any STOMP message
broker (eg. RabbitMQ).
SockJS is a browser JS
library that provides a
WebSocket-like object [8]
SockJS uses native
WebSockets or a variety of
browser-specific transport
protocols.
RabbitMQ provides a plugin that implements STOMP over
SockJS: Web-Stomp plugin [9].
It is very simple to setup and use.
full-stack-bus ballgame example
application example: multiplayer ping-pong
[10] https://github.com/javierarilos/full-stack-bus-ballgame
postal.js
classi
ficati
on
game
log
ball
mgmt
score
aggregator
μService
ballgame UX
aggregated
scores and
classification gamelog
playfield
rabbit-
>postal
rabbit-
>postal
logical structure & messages
ball
management classification gamelogball
managementball
management
classification
classification
score
aggregator
gamelog
gamelog
topic/ballgamequeue/balls
sendBall
receiveBall
single.score
single.*
aggregated.scores
single.score
aggregated.scores
rabbit-
>postal
N x Browser
RabbitMQ
Node.js
gamelog
gameloggame
management
single.new-player
single.pong
single.ping
single.ping-fail
single.ball-picked
understood, show me the code!!!!
➔ RabbitMQ connection and subscriptions
http://bit.ly/1Gy7JcR#L140
➔ postal.js subscriptions
http://bit.ly/1Gy7JcR#L177
➔ routing msgs: RabbitMQ => postal.js
http://bit.ly/1Gy7JcR#L133
➔ sending a message to RabbitMQ
http://bit.ly/1Gy7JcR#L117
➔ aggregate scores μ-service
http://bit.ly/1Gy9V4f
we are done
with the
full stack
bus thing...
thank you
for your
attention!
media used. thanks to:
➔ Quentin Lebourgeois https://www.flickr.com/photos/quentinlebourgeois/5514792500/in/photostream/
➔ pargon https://flic.kr/p/4J3Yqo
➔ chriscroninimages www.flickr.com/photos/chriscroninimages/29963364
➔ Jim Landon https://flic.kr/p/p3zyZv

Full Stack Bus with Javascript, RabbitMQ and Postal.js

  • 1.
    full-stack-bus communicating ALL yourapplications with RabbitMQ, postal.js and javascript javier arias losada @javier_arilos
  • 2.
    imagine... imagine your appneeds growing (*) it’s easy if you try (*) by growing I mean functionality and/or performance and/or scalability
  • 3.
    message bus A messagebus enables separate applications to work together, but in a decoupled fashion [1]. [1] http://bit.ly/1GI9W3B
  • 4.
    message what? Message bustechnologies have been used in backend for more than 20 years: IBM MQSeries in 1992 [2]. [2] http://bit.ly/1GIbV8f
  • 5.
    did you saybackend? Nowadays we can use message bus in the browser with the help of libraries such as postal.js [3]. [3] http://bit.ly/1zozbq9
  • 6.
  • 7.
    seriously, what’s full-stack-bus? Byuniting frontend and backend bus technologies we can create applications that work out together in a decoupled fashion. frontend => frontend frontend => backend backend => frontend backend => backend
  • 8.
    … but Ialready do that!!!! frontend => frontend: eventEmitters, listeners, global variables... frontend => backend: HTTP, Websockets... backend => frontend: Websockets, Long-polling... backend => backend : HTTP, sockets, shared Db... Some of this are good mechanisms. ...others are just antipatterns… Unifying approachs has its own beauty.
  • 9.
    why then, amessage bus? Message bus allow to offer decoupled interfaces, based in Events/Messages. No callbacks, no request-reply, producers and consumers are decoupled. Off-the-shelf communication patterns: topics, queues, ...
  • 10.
    is it forme? Probably not. Message bus is not everybody’s cup of tea. If your platform is growing a lot in terms of load and/or complexity then it will help.
  • 11.
    can we nowstart with the tech? This is one possible way to communicate all your applications. postal.js js module js module js module RabbitMQ STOMP over Websokets (SockJS) μService μService μService
  • 12.
    RabbitMQ RabbitMQ is aMessage Broker implementing of the AMQP protocol. [4] Fast and easy to use. Open source :-) Almost certainly it is supported in your language / platform Very advanced concepts: ● Messaging: exchanges, queues, routing, … ● Built-in clustering and replication [4] http://www.rabbitmq.com
  • 13.
    Postal.js JS pub/sub librarysupporting some advanced subscription features [5] ➔ in-memory message bus - very loosely inspired by AMQP ➔ runs in the browser, or on the server using node.js ➔ only pub/sub, no queues ➔ opensource (> 1K in github) [5] https://github.com/postaljs/postal.js
  • 14.
    javascript Javascript is THEfull-stack language: runs on the client, server, databases and even on a toaster [6] [6] http://bit.ly/1uX9s44 In our sample game: ➔ node.js: μ-services ➔ angular: almost magical binding .js
  • 15.
    STOMP SockJS [7] http://stomp.github.io/ [8]https://github.com/sockjs [9] http://www.rabbitmq.com/web-stomp.html STOMP Simple Text Orientated Messaging Protocol [7]. STOMP clients communicate with any STOMP message broker (eg. RabbitMQ). SockJS is a browser JS library that provides a WebSocket-like object [8] SockJS uses native WebSockets or a variety of browser-specific transport protocols. RabbitMQ provides a plugin that implements STOMP over SockJS: Web-Stomp plugin [9]. It is very simple to setup and use.
  • 16.
    full-stack-bus ballgame example applicationexample: multiplayer ping-pong [10] https://github.com/javierarilos/full-stack-bus-ballgame postal.js classi ficati on game log ball mgmt score aggregator μService
  • 17.
  • 18.
    rabbit- >postal rabbit- >postal logical structure &messages ball management classification gamelogball managementball management classification classification score aggregator gamelog gamelog topic/ballgamequeue/balls sendBall receiveBall single.score single.* aggregated.scores single.score aggregated.scores rabbit- >postal N x Browser RabbitMQ Node.js gamelog gameloggame management single.new-player single.pong single.ping single.ping-fail single.ball-picked
  • 19.
    understood, show methe code!!!! ➔ RabbitMQ connection and subscriptions http://bit.ly/1Gy7JcR#L140 ➔ postal.js subscriptions http://bit.ly/1Gy7JcR#L177 ➔ routing msgs: RabbitMQ => postal.js http://bit.ly/1Gy7JcR#L133 ➔ sending a message to RabbitMQ http://bit.ly/1Gy7JcR#L117 ➔ aggregate scores μ-service http://bit.ly/1Gy9V4f
  • 20.
    we are done withthe full stack bus thing... thank you for your attention!
  • 21.
    media used. thanksto: ➔ Quentin Lebourgeois https://www.flickr.com/photos/quentinlebourgeois/5514792500/in/photostream/ ➔ pargon https://flic.kr/p/4J3Yqo ➔ chriscroninimages www.flickr.com/photos/chriscroninimages/29963364 ➔ Jim Landon https://flic.kr/p/p3zyZv