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
Messages queues don't need to be scary.
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Glen Mailer
October 14, 2013
Technology
140
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
160
How to React Appropriately
glenjamin
1
600
Bumping our Stack to PHP 5.5
glenjamin
0
290
Message Queues for Everyone
glenjamin
1
230
Upgrading from PHP 5.3 to 5.5
glenjamin
1
1.3k
Other Decks in Technology
See All in Technology
ミイダス株式会社 テックチームのご紹介 / MIIDAS Tech Team
miidas
0
160
ビジネスを止めない技術的負債の返済のための戦略とその手法 - 技術的負債と向き合う / Complexity and Simplicity
soudai
PRO
3
640
並行性の問題を防げ!実践トランザクション入門
occhi
0
280
形式手法を使って仕様をコーディングしよう
mikanichinose
0
180
LocalStack を使ったサーバーレスアプリケーション開発 / Serverless Development with LocalStack
kakakakakku
0
210
[2026 Oracle Technical Deep Dive] AI時代のデータベース基盤をどう選ぶ? Exadata Database Serviceの選択肢と使い分け (2026年9月17日開催)
oracle4engineer
PRO
0
230
2026-10-01_MagicPod_QAハーネスエンジニアリングとQA組織の未来像
ynisqa1988
1
540
ファミコンでPHPを動かす / PHP on the Famicom side b
tomzoh
0
140
Datadog の学び方 - あるいは、オブザーバビリティを学ぶとは何か
mananyuki
1
490
FinTech 1-2 : Overview of FinTech
ks91
PRO
0
150
AI時代だからこそ推したい!Gitコマンド再入門
munakata
0
150
雪かき部 #7 もう怖くない!SELECT文!
foursue
0
280
Featured
See All Featured
Mind Mapping
helmedeiros
1
390
How to Talk to Developers About Accessibility
jct
2
560
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
300
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.3k
Bash Introduction
62gerente
615
220k
The agentic SEO stack - context over prompts
schlessera
0
970
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
エンジニアに許された特別な時間の終わり
watany
109
250k
Being A Developer After 40
akosma
91
590k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
530
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")