SlideShare a Scribd company logo
Messaging Standards and Systems
AMQP & RabbitMQ
Gavin M. Roy
VP of Architecture
AWeber Communications
Twitter: @Crad
POSSCON
April 14, 2015
About Me
VP of Architecture

AWeber Communications

Blame me for pika, rabbitpy,
pamqp, and a handful of
RabbitMQ plugins

Blog: https://gavinroy.com 

Github: https://github.com/gmr

Book: http://manning.com/roy
Advanced Message Queueing Protocol
❖ Open Standard
❖ Platform and Vendor Neutral
❖ Multiple Versions
AMQP Timeline
2003
2005
2006
2008
2011
Initial Specification
Working Group formed
AMQP 0-8
AMQP 0-9-1
OASIS
AMQP 1.0
AMQP Working Group
❖ JPMorgan Chase
❖ Cisco Systems
❖ IONA Technologies
❖ iMatrix
❖ RedHat
❖ TWIST
❖ Bank of America
❖ Barclays
❖ Credit Suisse
❖ Deutsche Börse Systems
❖ Goldman Sachs
❖ HCL Technologies
❖ Progress Software
❖ IIT Software
❖ INETCO Systems Ltd.
❖ Informatica Corporation
❖ Microsoft Corporation
❖ my-Channels
❖ Novell
❖ Solace Systems
❖ Tervala, Inc.
❖ VMWare
❖ WSO2
Competing AMQP Standards
≠
0-8
&
0-9-1
1.0
AMQP 0-9-1
❖ Currently has wider support than AMQP 1.0
❖ Multiple Broker Implementations: 

RabbitMQ, Apache Qpid, and SwiftMQ to name a few
❖ Specifies a Model and Protocol
Native AMQP 0-8/0-9-1 Clients
C
Clojure
Cobol
Common Lisp
Delphi
Erlang
Go
Groovy
Haskell
Java
JavaScript
.NET
OCaml
Perl
PHP
Python
Ruby
Scala
❖ Exchange

Receives and route messages
❖ Message Queue

Stores messages until they can be

consumed
❖ Binding

Defines the relationship between an Exchange and Queue and provides
routing criteria
Advanced Message Queueing Model
X
Exchange
Binding
Message Queue
Routing Keys
❖ Provided when publishing a message
❖ Compared against binding keys by exchanges
❖ Ideally provide context to the message:
❖ Connote the type of the message
❖ Categorize the content in the message
❖ Specify the type of consumer that should receive it
Advanced Message Queueing Protocol
❖ Compact, binary frame format wire protocol
❖ Bi-directional RPC
❖ Commands consist of Classes and Methods:
❖ Example Request:



Queue.Declare(name=“foo”)
❖ Response:



Queue.DeclareOk(messages=0, consumers=0)
Common AMQP Terms
❖ Broker

A server that implements AMQP
❖ Producer or Publisher

A client application that sends messages to a broker
❖ Consumer

A client application that reads messages from a queue
Publishers and Consumers
CP
Multiple Publishers
CP
P
P
Multiple Consumers
C
C
C
P
AMQP Messages
❖ Comprised of 3 or more frames:
❖ Method Frame

Basic.Publish, Basic.Deliver, etc
❖ Content Header with body size & message properties 

timestamp, message-id, app-id, etc
❖ n Body Frames with the opaque message payload
AMQP 0-9-1 Issues & Gotchas
❖ Ambiguous
❖ Authentication
❖ Asynchronous
❖ Connection Negotiation
❖ Exceptions
!
RabbitMQ
❖ Open Source (MPL)
❖ Written in Erlang/OTP
❖ Developed/Maintained by Pivotal
❖ Multi-Protocol

AMQP 0-9-1 & 1.0, MQTT, STOMP, XMPP,
HTTP, Web-STOMP & More
❖ Roots in AMQP 0-8/0-9-1
Who Uses It?
Agora Games
Chef
Google AdMob
Instagram
MeetMe
Mercado Libre
Mozilla
NASA
New York Times
National Science Foundation
Openstack
Rapportive
Reddit
Soundcloud
(and many more)
Why Use RabbitMQ?
❖ Create loosely-coupled applications
❖ Communicate across applications or platforms
❖ Tap into pre-existing message flows for new purposes
❖ Scale-out clustering for growth, throughput, and HA
❖ Federation for WAN latencies and network partitions
❖ Extensible plugin-in architecture
RabbitMQ Extensions to AMQP
Authentication Failure
Exchange to Exchange Bindings
Delivery Confirmations
Basic.Nack
Consumer cancellations
Consumer priorities
Dead Letter Exchanges
Alternate Exchanges
Connection blocking
Message CC & BCC Routing
Queue Length Limits
Per Queue Message TTL
Per Message TTL
Queue TTL
Message User ID Validation
Auto-delete exchanges
RabbitMQ Clustering
❖ LAN Only
❖ Adds highly-available queues
❖ Is cohesive, publish and consume
from any node
❖ Leverages native Erlang clustering
and communication
❖ Has multiple strategies for dealing
with network partitions
❖ Manually configured via
configuration or command line*
RabbitMQ Federation
❖ Provides loosely coupled inter-
node/cluster RabbitMQ
communication
❖ Connect multiple RabbitMQ
clusters across data centers or the
Internet
❖ Can be applied to both exchanges
and queues
Cluster A
X
Cluster B
X
Cluster C
X
RabbitMQ Plugins
amqp1_0

Adds AMQP 1.0 support to
RabbitMQ
auth-backend-amqp

AMQP RPC for Authentication
auth-backend-ldap

Authenticate via an external LDAP
server
autocluster-consul

Automatically create clusters using
Consul
msg_store_eleveldb_index

LevelDB storage for queue messages
presence-exchange

Publishes messages upon binding
changes
rabbitmq-top

Top like view of RabbitMQ
processes in the management UI
sharding

Scale out RabbitMQ with automatic
queue sharding
(and many more)
Message Routing
Built-In Exchange Types
❖ Direct

String matching on the routing key
❖ Fanout

No routing key, messages delivered to all bound queues
❖ Topic

Pattern matching in the routing key
❖ Headers

No routing key, value matching in the headers property
Topic Exchange Binding Keys
Routing Key: namespace.delimited.keys
#

Receive all messages
namespace.#

Receive all messages in namespace
namespace.delimited.*

Receive all namespace.delimited messages
namespace.*.keys

Receive all namespace messages ending with keys
Exchange to Exchange Binding
X
X
X
Queue
Queue
Queue
Queue
Queue
Queue
Messages published into a topic exchange are
routed to two other exchanges and a queue
Messages published into the consistent-hashing
exchange are distributed amongst three queues
Messages published into a direct
exchange routed to two queues
P
Alternate Exchanges
P X
Unroutable
Messages
X
Unroutable messages are
sent to an alternate exchange
Dead Letter Exchanges
P X
Reject Queue
Queue C
X
Consumer rejects the
message without requeue
Dead-Letter Exchange
routes the message
Exchange Plugins
Consistent Hashing

Distribute messages via hashed value
of routing key
Event

Publishes messages on AMQP events
such as queue creation
Random

Distribute messages across all bound
queues randomly
PostgreSQL LISTEN

Subscribes to and publishes
PostgreSQL notifications
Recent History

Sends the last n messages to any
newly bound queue
Reverse Topic

Allows for routing patterns at publish
time and not via binding
Riak Storage

Stores messages published through
the exchange into Riak
Script Exchange

Calls out to external scripts for
message routing
Performance Considerations
Publishing Performance Scale
Persisted
M
essages
Transactions
H
A
Q
ueues
Publisherconfirm
s
N
o
guarantees
N
otification
on
failureAlternate
exchanges
H
A
Q
ueues
w
/Transactions
Persisted Messages IO Model
Disk
Queue
Message Queue
Queue
Messages with delivery-mode 2 sent
into RabbitMQ are persisted to disk
Pointers to the message are placed
in the queue data structures
When the message is no longer in
a queue, it is removed from disk
HA Queues & Performance
Queue
Queue
Queue
P
RabbitMQ Cluster
A publisher sends to any
node in a RabbitMQ cluster
The RabbitMQ servers in the
cluster synchronize the state
of the message in the queue
The message that was published is put in
the queue and is stored on each server
Consumer Performance Scale
G
etting
M
essages
C
onsum
ing
and
using
Transactions
C
onsum
e
w
ith
Acknow
ledgem
ents
C
onsum
ing
w
ith
"N
o
Ack
M
ode"enabled
C
onsum
ing
w
ith
Acknow
ledgem
ents
and
Q
oS
>
1
Operational Concerns
Trending & Monitoring
❖ RabbitMQ Management Plugin provides internal stats
❖ Queue depths, connection counts, throughput, memory
usage, etc
❖ Monitor with common tools such as Nagios or Sensu to
services such as Boundary and NewRelic
❖ Stream based monitoring with Riemann for anomaly
detection
Thoughts on Configuration
❖ Use configuration management!
❖ Even for exchanges, queues, and bindings if possible
❖ Helpful for disaster recovery
❖ Use RabbitMQ’s Policies when possible
❖ Exchanges and queues are immutable
❖ Deleting and redeclaring for changes can be
disruptive
Sample Usage Patterns
Evolve Tightly-Coupled Applications
Application DB
Decoupling Database Writes
Application C DB
Listen for Database Notifications
X Queue
Multi-Purposed Messages
C
C
C
P
Queue
DB
Cloud
GraphiteQueue
Queue
X
RPC
C / PC / P
P / C
C / PResponse Queue
X
X
Worker
Queue
Front-end web app
receives a request
Internet
App publishes RPC request
One of the subscribed
worker consumers receives
the RPC request
After processing the request,
the worker publishes the replyApp receives the reply
from the response queue
App replies to client
Delayed Messages
WARNING: This pattern is a hack and can cause undesirable situations should the wait queue overwhelm the system!
P X
X
Wait Queue
Ready Queue C
The wait queue is declared with a
message TTL and a dead-letter exchangeMessages that will be delivered
later are routed to a wait queue
When a message times out due to
the TTL, it is published to the DLX
The internally re-published message is
routed to the queue with active consumers
HA RabbitMQ with Federation
Upstream Cluster A
Queue A
Queue B
Upstream Cluster B
Queue A
Queue B
Downstream Cluster A
Queue A
Queue B
Downstream Cluster B
Queue A
Queue B
HA Proxy 1
HA Proxy 2
P
P
P
C A
C B
Questions?

More Related Content

PDF
Messaging Standards and Systems - AMQP & RabbitMQ
All Things Open
 
PDF
RabbitMQ fairly-indepth
Wee Keat Chin
 
PDF
Introduction to AMQP Messaging with RabbitMQ
Dmitriy Samovskiy
 
PPTX
The RabbitMQ Message Broker
Martin Toshev
 
PDF
Messaging with amqp and rabbitmq
Selasie Hanson
 
PPTX
Message Broker System and RabbitMQ
University of Alabama at Birmingham
 
PDF
RabbitMQ & Hutch
Peter Hamilton
 
PDF
Distributed messaging with AMQP
Wee Keat Chin
 
Messaging Standards and Systems - AMQP & RabbitMQ
All Things Open
 
RabbitMQ fairly-indepth
Wee Keat Chin
 
Introduction to AMQP Messaging with RabbitMQ
Dmitriy Samovskiy
 
The RabbitMQ Message Broker
Martin Toshev
 
Messaging with amqp and rabbitmq
Selasie Hanson
 
Message Broker System and RabbitMQ
University of Alabama at Birmingham
 
RabbitMQ & Hutch
Peter Hamilton
 
Distributed messaging with AMQP
Wee Keat Chin
 

What's hot (20)

PDF
AMQP with RabbitMQ
Spyros Papageorgiou
 
PDF
The Future of Messaging: RabbitMQ and AMQP
Eberhard Wolff
 
PDF
Messaging with RabbitMQ and AMQP
Eberhard Wolff
 
KEY
Real time system_performance_mon
Tomas Doran
 
PDF
An update from the RabbitMQ team - Michael Klishin
RabbitMQ Summit
 
PPT
Rabbit MQ introduction
Sitg Yao
 
PPT
Amqp Basic
Rahul Agrawal
 
PDF
Full Stack Bus with Javascript, RabbitMQ and Postal.js
Javier Arias Losada
 
KEY
RabbitMQ And Nanite
mattmatt
 
PDF
[@NaukriEngineering] Messaging Queues
Naukri.com
 
PDF
AMQP for phpMelb
Wee Keat Chin
 
PPTX
What is RabbitMQ ?
AIMDek Technologies
 
PPTX
High powered messaging with RabbitMQ
James Carr
 
PDF
What we've learned from running thousands of production RabbitMQ clusters - L...
RabbitMQ Summit
 
PDF
A Closer Look at RabbitMQ
Kyumars Sheykh Esmaili
 
PPTX
Java Messaging with AMQP and RabbitMQ
Maxim Konovalov
 
PDF
What’s New in RabbitMQ 3.8?
VMware Tanzu
 
ODP
Introduction To RabbitMQ
Knoldus Inc.
 
PDF
RabbitMQ in PHP
Sergio Sicari
 
PPT
Easy enterprise application integration with RabbitMQ and AMQP
Rabbit MQ
 
AMQP with RabbitMQ
Spyros Papageorgiou
 
The Future of Messaging: RabbitMQ and AMQP
Eberhard Wolff
 
Messaging with RabbitMQ and AMQP
Eberhard Wolff
 
Real time system_performance_mon
Tomas Doran
 
An update from the RabbitMQ team - Michael Klishin
RabbitMQ Summit
 
Rabbit MQ introduction
Sitg Yao
 
Amqp Basic
Rahul Agrawal
 
Full Stack Bus with Javascript, RabbitMQ and Postal.js
Javier Arias Losada
 
RabbitMQ And Nanite
mattmatt
 
[@NaukriEngineering] Messaging Queues
Naukri.com
 
AMQP for phpMelb
Wee Keat Chin
 
What is RabbitMQ ?
AIMDek Technologies
 
High powered messaging with RabbitMQ
James Carr
 
What we've learned from running thousands of production RabbitMQ clusters - L...
RabbitMQ Summit
 
A Closer Look at RabbitMQ
Kyumars Sheykh Esmaili
 
Java Messaging with AMQP and RabbitMQ
Maxim Konovalov
 
What’s New in RabbitMQ 3.8?
VMware Tanzu
 
Introduction To RabbitMQ
Knoldus Inc.
 
RabbitMQ in PHP
Sergio Sicari
 
Easy enterprise application integration with RabbitMQ and AMQP
Rabbit MQ
 
Ad

Viewers also liked (6)

PDF
Automating OpenStack Deployment with Fuel
Tomasz Zen Napierala
 
PPTX
Commication Framework in OpenStack
Sean Chang
 
PDF
[2015-05월 세미나] 파이선 초심자의 Openstack
OpenStack Korea Community
 
PDF
OpenStack DevStack Install - 2부 (Multi-nodes)
Ian Choi
 
PPTX
Openstack Study Nova 1
Jinho Shin
 
PDF
오픈스택 멀티노드 설치 후기
영우 김
 
Automating OpenStack Deployment with Fuel
Tomasz Zen Napierala
 
Commication Framework in OpenStack
Sean Chang
 
[2015-05월 세미나] 파이선 초심자의 Openstack
OpenStack Korea Community
 
OpenStack DevStack Install - 2부 (Multi-nodes)
Ian Choi
 
Openstack Study Nova 1
Jinho Shin
 
오픈스택 멀티노드 설치 후기
영우 김
 
Ad

Similar to Messaging Standards and Systems - AMQP & RabbitMQ (20)

PDF
Enterprise Messaging with RabbitMQ.pdf
Ortus Solutions, Corp
 
PPTX
Messaging-as-a-Service Rivieradev 2017
Ulf Lilleengen
 
PPTX
Rabbit MQ
Tran Thanh Thi
 
PDF
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
JAX London
 
PPTX
Beyond REST and RPC: Asynchronous Eventing and Messaging Patterns
Clemens Vasters
 
PPT
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
John Staveley
 
PDF
Big Data Streams Architectures. Why? What? How?
Anton Nazaruk
 
PDF
Module: Mutable Content in IPFS
Ioannis Psaras
 
PDF
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
StreamNative
 
PDF
Multi-platform Enterprise Messaging with RabbitMQ
Ortus Solutions, Corp
 
PPTX
Captial One: Why Stream Data as Part of Data Transformation?
ScyllaDB
 
PDF
Multi-language/multi-OS communication using RabbitMQ
Wil de Bruin
 
PDF
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de Bruin
Ortus Solutions, Corp
 
PDF
Hail hydrate! from stream to lake using open source
Timothy Spann
 
PPTX
Message Broker implementation in Kubernetes
Suman Chakraborty
 
PDF
Devfest uk & ireland using apache nifi with apache pulsar for fast data on-r...
Timothy Spann
 
PPTX
HPC Controls Future
rcastain
 
PPTX
Mule with rabbitmq
Anirban Sen Chowdhary
 
PDF
Open Source Bristol 30 March 2022
Timothy Spann
 
PDF
Message queues
Ahmad karawash
 
Enterprise Messaging with RabbitMQ.pdf
Ortus Solutions, Corp
 
Messaging-as-a-Service Rivieradev 2017
Ulf Lilleengen
 
Rabbit MQ
Tran Thanh Thi
 
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
JAX London
 
Beyond REST and RPC: Asynchronous Eventing and Messaging Patterns
Clemens Vasters
 
Messaging - RabbitMQ, Azure (Service Bus), Docker and Azure Functions
John Staveley
 
Big Data Streams Architectures. Why? What? How?
Anton Nazaruk
 
Module: Mutable Content in IPFS
Ioannis Psaras
 
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
StreamNative
 
Multi-platform Enterprise Messaging with RabbitMQ
Ortus Solutions, Corp
 
Captial One: Why Stream Data as Part of Data Transformation?
ScyllaDB
 
Multi-language/multi-OS communication using RabbitMQ
Wil de Bruin
 
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de Bruin
Ortus Solutions, Corp
 
Hail hydrate! from stream to lake using open source
Timothy Spann
 
Message Broker implementation in Kubernetes
Suman Chakraborty
 
Devfest uk & ireland using apache nifi with apache pulsar for fast data on-r...
Timothy Spann
 
HPC Controls Future
rcastain
 
Mule with rabbitmq
Anirban Sen Chowdhary
 
Open Source Bristol 30 March 2022
Timothy Spann
 
Message queues
Ahmad karawash
 

More from POSSCON (20)

PDF
Why Meteor.JS?
POSSCON
 
PDF
Vagrant 101
POSSCON
 
PDF
Tools for Open Source Systems Administration
POSSCON
 
PPTX
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
POSSCON
 
PPTX
Accelerating Application Delivery with OpenShift
POSSCON
 
PDF
Openstack 101
POSSCON
 
ODP
Community Building: The Open Source Way
POSSCON
 
PPTX
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
POSSCON
 
PDF
Software Defined Networking (SDN) for the Datacenter
POSSCON
 
PDF
Application Security on a Dime: A Practical Guide to Using Functional Open So...
POSSCON
 
ODP
Why Your Open Source Story Matters
POSSCON
 
PDF
How YARN Enables Multiple Data Processing Engines in Hadoop
POSSCON
 
PPTX
Google Summer of Code
POSSCON
 
PDF
Introduction to Hadoop
POSSCON
 
PDF
How to Use Cryptography Properly: The Common Mistakes People Make When Using ...
POSSCON
 
PPTX
Cyber Security and Open Source
POSSCON
 
PDF
Intro to AngularJS
POSSCON
 
PDF
Docker 101: An Introduction
POSSCON
 
PDF
Graph the Planet!
POSSCON
 
PDF
Software Freedom Licensing: What You Must Know
POSSCON
 
Why Meteor.JS?
POSSCON
 
Vagrant 101
POSSCON
 
Tools for Open Source Systems Administration
POSSCON
 
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
POSSCON
 
Accelerating Application Delivery with OpenShift
POSSCON
 
Openstack 101
POSSCON
 
Community Building: The Open Source Way
POSSCON
 
I Know It Was MEAN, But I Cut the Cord to LAMP Anyway
POSSCON
 
Software Defined Networking (SDN) for the Datacenter
POSSCON
 
Application Security on a Dime: A Practical Guide to Using Functional Open So...
POSSCON
 
Why Your Open Source Story Matters
POSSCON
 
How YARN Enables Multiple Data Processing Engines in Hadoop
POSSCON
 
Google Summer of Code
POSSCON
 
Introduction to Hadoop
POSSCON
 
How to Use Cryptography Properly: The Common Mistakes People Make When Using ...
POSSCON
 
Cyber Security and Open Source
POSSCON
 
Intro to AngularJS
POSSCON
 
Docker 101: An Introduction
POSSCON
 
Graph the Planet!
POSSCON
 
Software Freedom Licensing: What You Must Know
POSSCON
 

Recently uploaded (20)

PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Doc9.....................................
SofiaCollazos
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 

Messaging Standards and Systems - AMQP & RabbitMQ

  • 1. Messaging Standards and Systems AMQP & RabbitMQ Gavin M. Roy VP of Architecture AWeber Communications Twitter: @Crad POSSCON April 14, 2015
  • 2. About Me VP of Architecture
 AWeber Communications Blame me for pika, rabbitpy, pamqp, and a handful of RabbitMQ plugins Blog: https://gavinroy.com Github: https://github.com/gmr Book: http://manning.com/roy
  • 3. Advanced Message Queueing Protocol ❖ Open Standard ❖ Platform and Vendor Neutral ❖ Multiple Versions
  • 4. AMQP Timeline 2003 2005 2006 2008 2011 Initial Specification Working Group formed AMQP 0-8 AMQP 0-9-1 OASIS AMQP 1.0
  • 5. AMQP Working Group ❖ JPMorgan Chase ❖ Cisco Systems ❖ IONA Technologies ❖ iMatrix ❖ RedHat ❖ TWIST ❖ Bank of America ❖ Barclays ❖ Credit Suisse ❖ Deutsche Börse Systems ❖ Goldman Sachs ❖ HCL Technologies ❖ Progress Software ❖ IIT Software ❖ INETCO Systems Ltd. ❖ Informatica Corporation ❖ Microsoft Corporation ❖ my-Channels ❖ Novell ❖ Solace Systems ❖ Tervala, Inc. ❖ VMWare ❖ WSO2
  • 7. AMQP 0-9-1 ❖ Currently has wider support than AMQP 1.0 ❖ Multiple Broker Implementations: 
 RabbitMQ, Apache Qpid, and SwiftMQ to name a few ❖ Specifies a Model and Protocol
  • 8. Native AMQP 0-8/0-9-1 Clients C Clojure Cobol Common Lisp Delphi Erlang Go Groovy Haskell Java JavaScript .NET OCaml Perl PHP Python Ruby Scala
  • 9. ❖ Exchange
 Receives and route messages ❖ Message Queue
 Stores messages until they can be
 consumed ❖ Binding
 Defines the relationship between an Exchange and Queue and provides routing criteria Advanced Message Queueing Model X Exchange Binding Message Queue
  • 10. Routing Keys ❖ Provided when publishing a message ❖ Compared against binding keys by exchanges ❖ Ideally provide context to the message: ❖ Connote the type of the message ❖ Categorize the content in the message ❖ Specify the type of consumer that should receive it
  • 11. Advanced Message Queueing Protocol ❖ Compact, binary frame format wire protocol ❖ Bi-directional RPC ❖ Commands consist of Classes and Methods: ❖ Example Request:
 
 Queue.Declare(name=“foo”) ❖ Response:
 
 Queue.DeclareOk(messages=0, consumers=0)
  • 12. Common AMQP Terms ❖ Broker
 A server that implements AMQP ❖ Producer or Publisher
 A client application that sends messages to a broker ❖ Consumer
 A client application that reads messages from a queue
  • 16. AMQP Messages ❖ Comprised of 3 or more frames: ❖ Method Frame
 Basic.Publish, Basic.Deliver, etc ❖ Content Header with body size & message properties 
 timestamp, message-id, app-id, etc ❖ n Body Frames with the opaque message payload
  • 17. AMQP 0-9-1 Issues & Gotchas ❖ Ambiguous ❖ Authentication ❖ Asynchronous ❖ Connection Negotiation ❖ Exceptions !
  • 18. RabbitMQ ❖ Open Source (MPL) ❖ Written in Erlang/OTP ❖ Developed/Maintained by Pivotal ❖ Multi-Protocol
 AMQP 0-9-1 & 1.0, MQTT, STOMP, XMPP, HTTP, Web-STOMP & More ❖ Roots in AMQP 0-8/0-9-1
  • 19. Who Uses It? Agora Games Chef Google AdMob Instagram MeetMe Mercado Libre Mozilla NASA New York Times National Science Foundation Openstack Rapportive Reddit Soundcloud (and many more)
  • 20. Why Use RabbitMQ? ❖ Create loosely-coupled applications ❖ Communicate across applications or platforms ❖ Tap into pre-existing message flows for new purposes ❖ Scale-out clustering for growth, throughput, and HA ❖ Federation for WAN latencies and network partitions ❖ Extensible plugin-in architecture
  • 21. RabbitMQ Extensions to AMQP Authentication Failure Exchange to Exchange Bindings Delivery Confirmations Basic.Nack Consumer cancellations Consumer priorities Dead Letter Exchanges Alternate Exchanges Connection blocking Message CC & BCC Routing Queue Length Limits Per Queue Message TTL Per Message TTL Queue TTL Message User ID Validation Auto-delete exchanges
  • 22. RabbitMQ Clustering ❖ LAN Only ❖ Adds highly-available queues ❖ Is cohesive, publish and consume from any node ❖ Leverages native Erlang clustering and communication ❖ Has multiple strategies for dealing with network partitions ❖ Manually configured via configuration or command line*
  • 23. RabbitMQ Federation ❖ Provides loosely coupled inter- node/cluster RabbitMQ communication ❖ Connect multiple RabbitMQ clusters across data centers or the Internet ❖ Can be applied to both exchanges and queues Cluster A X Cluster B X Cluster C X
  • 24. RabbitMQ Plugins amqp1_0
 Adds AMQP 1.0 support to RabbitMQ auth-backend-amqp
 AMQP RPC for Authentication auth-backend-ldap
 Authenticate via an external LDAP server autocluster-consul
 Automatically create clusters using Consul msg_store_eleveldb_index
 LevelDB storage for queue messages presence-exchange
 Publishes messages upon binding changes rabbitmq-top
 Top like view of RabbitMQ processes in the management UI sharding
 Scale out RabbitMQ with automatic queue sharding (and many more)
  • 26. Built-In Exchange Types ❖ Direct
 String matching on the routing key ❖ Fanout
 No routing key, messages delivered to all bound queues ❖ Topic
 Pattern matching in the routing key ❖ Headers
 No routing key, value matching in the headers property
  • 27. Topic Exchange Binding Keys Routing Key: namespace.delimited.keys #
 Receive all messages namespace.#
 Receive all messages in namespace namespace.delimited.*
 Receive all namespace.delimited messages namespace.*.keys
 Receive all namespace messages ending with keys
  • 28. Exchange to Exchange Binding X X X Queue Queue Queue Queue Queue Queue Messages published into a topic exchange are routed to two other exchanges and a queue Messages published into the consistent-hashing exchange are distributed amongst three queues Messages published into a direct exchange routed to two queues P
  • 29. Alternate Exchanges P X Unroutable Messages X Unroutable messages are sent to an alternate exchange
  • 30. Dead Letter Exchanges P X Reject Queue Queue C X Consumer rejects the message without requeue Dead-Letter Exchange routes the message
  • 31. Exchange Plugins Consistent Hashing
 Distribute messages via hashed value of routing key Event
 Publishes messages on AMQP events such as queue creation Random
 Distribute messages across all bound queues randomly PostgreSQL LISTEN
 Subscribes to and publishes PostgreSQL notifications Recent History
 Sends the last n messages to any newly bound queue Reverse Topic
 Allows for routing patterns at publish time and not via binding Riak Storage
 Stores messages published through the exchange into Riak Script Exchange
 Calls out to external scripts for message routing
  • 34. Persisted Messages IO Model Disk Queue Message Queue Queue Messages with delivery-mode 2 sent into RabbitMQ are persisted to disk Pointers to the message are placed in the queue data structures When the message is no longer in a queue, it is removed from disk
  • 35. HA Queues & Performance Queue Queue Queue P RabbitMQ Cluster A publisher sends to any node in a RabbitMQ cluster The RabbitMQ servers in the cluster synchronize the state of the message in the queue The message that was published is put in the queue and is stored on each server
  • 38. Trending & Monitoring ❖ RabbitMQ Management Plugin provides internal stats ❖ Queue depths, connection counts, throughput, memory usage, etc ❖ Monitor with common tools such as Nagios or Sensu to services such as Boundary and NewRelic ❖ Stream based monitoring with Riemann for anomaly detection
  • 39. Thoughts on Configuration ❖ Use configuration management! ❖ Even for exchanges, queues, and bindings if possible ❖ Helpful for disaster recovery ❖ Use RabbitMQ’s Policies when possible ❖ Exchanges and queues are immutable ❖ Deleting and redeclaring for changes can be disruptive
  • 43. Listen for Database Notifications X Queue
  • 45. RPC C / PC / P P / C C / PResponse Queue X X Worker Queue Front-end web app receives a request Internet App publishes RPC request One of the subscribed worker consumers receives the RPC request After processing the request, the worker publishes the replyApp receives the reply from the response queue App replies to client
  • 46. Delayed Messages WARNING: This pattern is a hack and can cause undesirable situations should the wait queue overwhelm the system! P X X Wait Queue Ready Queue C The wait queue is declared with a message TTL and a dead-letter exchangeMessages that will be delivered later are routed to a wait queue When a message times out due to the TTL, it is published to the DLX The internally re-published message is routed to the queue with active consumers
  • 47. HA RabbitMQ with Federation Upstream Cluster A Queue A Queue B Upstream Cluster B Queue A Queue B Downstream Cluster A Queue A Queue B Downstream Cluster B Queue A Queue B HA Proxy 1 HA Proxy 2 P P P C A C B