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
220
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Message Queues for Everyone
An intro to AMQP for Node.js developers
Glen Mailer
March 27, 2014
More Decks by Glen Mailer
See All by Glen Mailer
Are you afraid of dependencies?
glenjamin
0
160
How to React Appropriately
glenjamin
1
590
Bumping our Stack to PHP 5.5
glenjamin
0
280
Messages queues don't need to be scary.
glenjamin
1
140
Upgrading from PHP 5.3 to 5.5
glenjamin
1
1.3k
Other Decks in Technology
See All in Technology
制約理論(ToC)入門 2026版
recruitengineers
PRO
8
2.3k
20260807_第6回_関東kaggler会LT_claw系bot xangiと始める、"寂しくない" kaggle
sugupoko
0
280
つくって納得、つかって実感! 大規模言語モデルことはじめ ver2.0
recruitengineers
PRO
4
1.6k
LLM・AIエージェントシステムベストプラクティス
shibuiwilliam
6
1.3k
サイバー捜査員研修(後半)
nomizone
1
870
今こそ聞きたいソフトウェア設計 ドメイン駆動設計再入門
masuda220
PRO
17
7.3k
SO-101×VLAによる3色キューブのピック&プレース
abeja
0
200
Webアクセシビリティ入門 2026
recruitengineers
PRO
3
570
AIコーディングの次。コードレビューと理解負荷を解消して組織の開発生産性を高める
moongift
PRO
2
2.6k
Master Dataグループ紹介資料
sansan33
PRO
1
4.8k
システム思考で問題に対処する
yussak
0
290
Agent 時代の Kaggle 展望 / kaggle-in-the-agentic-era
upura
1
740
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
22k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
760
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
490
Into the Great Unknown - MozCon
thekraken
41
2.7k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
280
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
250
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.8k
We Have a Design System, Now What?
morganepeng
55
8.3k
For a Future-Friendly Web
brad_frost
183
10k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
470
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