Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Message Queues for Everyone
Search
Glen Mailer
March 27, 2014
Technology
1
180
Message Queues for Everyone
An intro to AMQP for Node.js developers
Glen Mailer
March 27, 2014
Tweet
Share
More Decks by Glen Mailer
See All by Glen Mailer
Are you afraid of dependencies?
glenjamin
0
140
How to React Appropriately
glenjamin
1
540
Bumping our Stack to PHP 5.5
glenjamin
0
250
Messages queues don't need to be scary.
glenjamin
1
110
Upgrading from PHP 5.3 to 5.5
glenjamin
1
1.2k
Other Decks in Technology
See All in Technology
M&Aで拡大し続けるGENDAのデータ活用を促すためのDatabricks権限管理 / AEON TECH HUB #22
genda
0
270
AR Guitar: Expanding Guitar Performance from a Live House to Urban Space
ekito_station
0
250
_第4回__AIxIoTビジネス共創ラボ紹介資料_20251203.pdf
iotcomjpadmin
0
140
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
1
770
202512_AIoT.pdf
iotcomjpadmin
0
150
ペアーズにおけるAIエージェント 基盤とText to SQLツールの紹介
hisamouna
2
1.7k
オープンソースKeycloakのMCP認可サーバの仕様の対応状況 / 20251219 OpenID BizDay #18 LT Keycloak
oidfj
0
190
Claude Skillsの テスト業務での活用事例
moritamasami
1
110
Identity Management for Agentic AI 解説
fujie
0
490
投資戦略を量産せよ 2 - マケデコセミナー(2025/12/26)
gamella
0
460
普段使ってるClaude Skillsの紹介(by Notebooklm)
zerebom
8
2.3k
マイクロサービスへの5年間 ぶっちゃけ何をしてどうなったか
joker1007
21
8.3k
Featured
See All Featured
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
350
Building Applications with DynamoDB
mza
96
6.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
47
Facilitating Awesome Meetings
lara
57
6.7k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
0
210
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
61k
The SEO Collaboration Effect
kristinabergwall1
0
310
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
230
GitHub's CSS Performance
jonrohan
1032
470k
HDC tutorial
michielstock
0
280
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.1k
Transcript
Message queues for everyone An intro workshop to AMQP For
Node.js Developers
AMQP
Advanced Message Queuing Protocol
0.9.1
None
Why?
Job Queue Event Stream Buffered RPC
Job Queue
Producer Consumer
Producer Consumer Producer
Producer Consumer Producer Consumer
Producer Consumer Producer Consumer
Exchange In Queue Out
Slow Operations Expensive Operations Brittle Operations
Producer c = create_channel q = c.queue("task") x = c.default_exchange
x.publish( "job1", "payload" ) Consumer c = create_channel q = c.queue("task") q.subscribe(worker) worker = fn(*message) { // do stuff }
Acknowledging Messages q = c.queue("task") q.subscribe(ack = TRUE, worker) worker
= fn(body, headers, info, m) { // do work m.acknowledge() }
Publishing Options Mandatory Will error if not queued Confirm Server
acknowledges receipt
Queue Declare Options Passive Don't create, get reference to existing
queue Durable Queue still exists after a broker restart
Event Stream
Producer Consumer Producer Consumer Consumer Consumer Producer
Messages Routing Key
Exchanges Fanout: all queues Direct: matching key Topic: key patterns
Exchange | Binding | Queue
Topic Exchange routing.key Exact match routing.*.key routing.#.key Wildcard matching routing.key
routing.a.key routing.b.key routing.a.b.key
(soft) Real-time updates User notifications Work distribution
Binding a Queue x = c.exchange("activity”) q = c.queue("alert") q.bind(x,
"balance.*") q.bind(x, "transfer.out") x.publish("balance.low") x.publish("transfer.in") x.publish("transfer.out")
Queue Declare Options Exclusive Only one consumer on this queue
at any time Auto Delete Queue is deleted after consumer disconnects
Simulator Demo
Buffered RPC
Producer Consumer
Smooth out Spikes Transparently scale Deferred Response
Message Header Reply To Correlation ID
Reply To reply = c.queue("abcdef") x.publish("request", headers: { replyTo: "abcdef"
}}) reply.subscribe(handleResponse)
Correlation ID x.publish("request1", headers: { replyTo: "abcdef", correlationId: "request1" })
x.publish("request2", headers: { replyTo: "abcdef", correlationId: "request2" })
Admin Interface Demo
Why not just use … ?
Redis pub/sub (Resque etc)
Beanstalkd
JMS Stomp
MQTT
ØMQ
Node.js Quickstart
npm install amqp
var amqp = require('amqp') var conn = amqp.createConnection( {
url: 'amqp://un:pw@host:5672/vhost' }, { reconnect: false } ) conn.on('ready', function() { // Do stuff })
var opts = { noDeclare: true } conn.queue(name, opts, function(q)
{ q.subscribe( { ack: true, prefetch: 1 }, onMessage ) }) function onMessage(body, meta, info, msg) { // do some stuff msg.acknowledge() }
var opts = { type: 'topic', noDeclare: true } conn.exchange(name,
opts, function(x) { x.publish('key', 'body', { contentType: 'text/json' }) })
Questions?
Lets go! http://amqp-nodejs.herokuapp.com https://addons.heroku.com/marketplace/rabbitmq-bigwig
@glenathan