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
Messages queues don't need to be scary.
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Glen Mailer
October 14, 2013
Technology
130
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Messages queues don't need to be scary.
An introduction tutorial to AMQP with RabbitMQ and Ruby.
Glen Mailer
October 14, 2013
More Decks by Glen Mailer
See All by Glen Mailer
Are you afraid of dependencies?
glenjamin
0
150
How to React Appropriately
glenjamin
1
580
Bumping our Stack to PHP 5.5
glenjamin
0
280
Message Queues for Everyone
glenjamin
1
210
Upgrading from PHP 5.3 to 5.5
glenjamin
1
1.2k
Other Decks in Technology
See All in Technology
Ruby::Boxでできること、Refinementsでできること
joker1007
3
410
[モダンアプリ勉強会]今更聞けないGit/GitHub入門
tsukuboshi
0
320
MIERUNE JCT 発表資料「宇宙から伊能忠敬ごっこ」
syuchimu
0
200
React、まだ楽しくて草
uhyo
7
4.2k
Agentic Web
dynamis
1
200
個人の発見を、組織の知恵に 〜生成AI活用を"探索"から"組織の仕組み"へ〜
kintotechdev
3
1.1k
AIソロプレナー時代に2ヶ月で20人増員した事業創造会社の開発組織の話
miyatakoji
0
430
「コーディング」しない人のための Claude Code 入門 ChatGPT の次の一歩 — 業務に組み込む 育成・共有・自動化
rfdnxbro
2
1.3k
AIを「創る」と「使う」の循環 — HRテックが実践するリアルなAI組織実装
taketo957
0
1.8k
Reliability in the Age of AI: Engineering for AI Velocity
rrreeeyyy
0
120
データ基盤をDataformで整えた話 〜 開発環境を添えて 〜
takapy
0
130
就職⽀援サービスにおけるキャリアアドバイザーのシフトスケジューリング
recruitengineers
PRO
1
110
Featured
See All Featured
The Mindset for Success: Future Career Progression
greggifford
PRO
0
360
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
480
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
840
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
140
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
The agentic SEO stack - context over prompts
schlessera
0
800
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
940
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.6k
Transcript
Message queues don't need to be scary An intro workshop
to AMQP
AMQP
Advanced Message Queuing Protocol
None
Why?
Job Queue Event Stream Buffered RPC
Job Queue
Producer Consumer
Producer Consumer Producer
Producer Consumer Producer Consumer
Producer Consumer Producer Consumer
Slow Operations Expensive Operations Brittle Operations
Producer c = create_channel q = c.queue("task") x = c.default_exchange
x.publish( "task", "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(worker, ack = TRUE) worker
= fn(info, metadata, body) { // do work c.acknowledge(info.delivery_tag) }
Publishing Options Mandatory Will error if not queued Immediate Will
error if no consumer available 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
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
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" })
Smooth out Spikes Transparently scale Deferred Response
Why not just use … ?
Delayed Job Resque / Sidekiq Beanstalkd
JMS Stomp MQTT
ØMQ
Ruby Quickstart
gem install bunny
require 'bunny' url = 'amqp://un:pw@host:5672/vhost' conn = Bunny.new(url) conn.start
ch = conn.create_channel ch.prefetch 1
declare_options = {:no_declare => true} q = ch.queue(name, options)
options = {:block => true, :ack => true} q.subscribe(options) do |info, meta, body| # do stuff ch.ack(info.delivery_tag) end
declare_options = {:no_declare => true} x = ch.topic("name", declare_options)
x.publish("message", :routing_key => "key")