Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Message Queues for Everyone
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Glen Mailer
March 27, 2014
Technology
230
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
610
Bumping our Stack to PHP 5.5
glenjamin
0
290
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
パスキーの自動テストはどこまでいけるのか
teamlab
PRO
0
250
Optunaの最新リリースv5.0について
pfn
PRO
0
120
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
460
DWH の限界突破! AI エージェント向け爆速リアルタイムデータ基盤 ClickHouse
jozono
1
480
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
180
AI × アーキテクト 第1・2章|生成AIの課題とアーキテクトの素養
daidaidai
0
170
パッチ更新でterraform initが落ちた日
grimoh
1
140
20261017福岡devIO 「AIは"良いダッシュボード"を作れるか?
jtakeda
0
150
実践! SRE × AI - ABEMA における AIOps -
tetsuya28
8
3.1k
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
4
1.1k
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
110
Rustuna: Rustによる高速なOptuna実装
pfn
PRO
0
190
Featured
See All Featured
Design in an AI World
tapps
1
350
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
520
A Tale of Four Properties
chriscoyier
163
24k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
270
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
340
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
550
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.3k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
3.4k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
430
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