SlideShare a Scribd company logo
Integrating PostgreSQL with RabbitMQ
Gavin M. Roy
April 4th, 2014
About Me
VP of Architecture

AWeber Communications
!
Blog: http://gavinroy.com
Twitter: @Crad
GitHub: https://github.com/gmr
!
RabbitMQ in Depth (MEAP)
http://manning.com/roy
RabbitMQ Primer
About RabbitMQ
• Message Oriented Middleware
• Primary identity is defined by AMQP 0-9-1
• Supports other protocols with Plugins:



AMQP 1.0, HTTP, MQTT, STOMP, XMPP, UDP,
WebStomp, and more
• Written in Erlang/OTP, is Open Source (MPL), and
is developed/maintained by Pivotal
Why RabbitMQ?
• Create loosely coupled architectures
• Decouple database write operations
• Communicate across application platforms
• Tap into pre-existing message flow for new purposes
• Scale-out clustering for growth, throughput & HA
• Federation for WAN latencies & network partitions
Native AMQP Clients
C
Clojure
Cobol
Common Lisp
Delphi
Erlang
Go
Groovy
Haskell
Java
JavaScript
.NET
OCaml
Perl
PHP
Python
Ruby
Scala
Who Uses It?
Agora Games
Chef
Google AdMob
Instagram
MeetMe
Mercado Libre
Mozilla
Nasa
New York Times
NSF
Openstack
Reddit
RabbitMQ Concepts
AMQP Message
Body
Properties
Message Properties
app-id
content-encoding
content-type
correlation-id
delivery-mode
expiration
headers
message-id
priority
reply-to
timestamp
type
user-id
Body
Properties
Publishers and Consumers
CP
Multiple Publishers
P
C
P
P
Multiple Consumers
P
C
C
C
AMQ Model
Exchange

defines routing behavior
Queue

stores messages in memory and
optionally on disk
Binding

defines relationship between
exchanges and queues
X
Queue
Binding
Routing Keys
• Provided when publishing a message
• Compared against binding keys by exchanges
• Example uses of a Routing Key:
• Connotate the type of message
• Designate the destination of a message
• Categorize the content in the message
Built-In Exchange Types
Direct

String matching on Routing Key
Fanout

No routing key, messages sent to all bound queues
Topic

Pattern matching in Routing Key
Headers

No routing key, string matching in the message headers
property
Topic Exchange Binding Keys
namespace.delimited.keys
#

Receive all messages
namespace.#

Receive all messages in the namespace
namespace.delimited.*

Receive all namespace.delimited messages
namespace.*.keys

Receive all namespace messages ending in keys
Example Exchange Plugins
Consistent Hashing

Distribute messages via
routing key hashed value
Pulse

Publish internal RabbitMQ
metrics via AMQP
Random

Distribute messages across
all bound queues randomly
Recent History

Stores last 20 messages to
any bound queue
Riak Storage 

Store received messages in
Riak"
Script Exchange

Calls out to external scripts
for routing behavior
Exchange to Exchange Bindings
X
X
X
Queue
Queue
Queue
to RabbitMQ
pg_amqp
• PostgreSQL Extension
• User-defined functions to publish via AMQP
• Developed by OmnTI
• Invoke from user-defined function
• Available on PGXN
Using pg_amqp
• Has table of AMQP broker connections
• Publishes body only AMQP messages
• Transactional publishing via amqp.publish
• Non-transactional via amqp.autonomous_publish
• Needs some love for additional features
https://github.com/gmr/On-Rabbits-and-ElephantsExample:
SELECT amqp.publish(broker_id,
'name',
'routing-key',
'message');
Publishing a Message
PgSQL Listen Exchange
• Exchange that issues LISTEN and publishes received
notifications to bound queues
• When routing messages, bindings are checked for the
routing key to match the NOTIFY channel
• Unobtrusive to PostgreSQL environment, native
constructs for publishing messages
• Requires PostgreSQL 9.0 and greater
• Body only messages*
Sending a Notification
psql (9.3.2)
Type "help" for help.
!
postgres=# timing
Timing is on.
postgres=# NOTIFY channel_name, 

‘Test notification';
NOTIFY
Time: 0.160 ms
Receiving a Notification
psql (9.3.2)
Type "help" for help.
!
postgres=# LISTEN channel_name;
!
(after NOTIFY issued)
!
Asynchronous notification "channel_name"
with payload "Test notification" received
from server process with PID 16749.
Integrating PostgreSql with RabbitMQ
Example Notification Message
to PostgreSQL
No direct integrations yet
Chapter 14
Creating a pgsql-storage
RabbitMQ plugin
Other ways?
via Consumer apps in the language of your choice
via Apache Flume with RabbitMQ Source,
PostgreSQL Sink
Questions?
rabbitmq-pgsql-listen-exchange

https://github.com/aweber/rabbitmq-pgsql-listen-exchange
pg_ampq

http://pgxn.org/dist/pg_amqp/
RabbitMQ in Depth 

44% off code pgcf (includes other books as well)

http://manning.com/roy/
Follow me on Twitter

@Crad

More Related Content

PDF
Understanding jvm gc advanced
PDF
Spark (Structured) Streaming vs. Kafka Streams
PDF
Battle of the Stream Processing Titans – Flink versus RisingWave
PDF
Kafka on Pulsar
PDF
Cassandra at eBay - Cassandra Summit 2012
PDF
Introduction to Spark Streaming
PPTX
Stability Patterns for Microservices
PDF
Apache Kafka Architecture & Fundamentals Explained
Understanding jvm gc advanced
Spark (Structured) Streaming vs. Kafka Streams
Battle of the Stream Processing Titans – Flink versus RisingWave
Kafka on Pulsar
Cassandra at eBay - Cassandra Summit 2012
Introduction to Spark Streaming
Stability Patterns for Microservices
Apache Kafka Architecture & Fundamentals Explained

What's hot (20)

PDF
[Meetup] a successful migration from elastic search to clickhouse
PDF
MySQL 8.0 EXPLAIN ANALYZE
PPTX
Reactive programming
PDF
Apache Spark Streaming in K8s with ArgoCD & Spark Operator
PDF
LINE's messaging service architecture underlying more than 200 million monthl...
PDF
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
PDF
Introduction to Apache Spark
PDF
Scalability, Availability & Stability Patterns
PDF
DPDK & Layer 4 Packet Processing
PPTX
Real Time UI with Apache Kafka Streaming Analytics of Fast Data and Server Push
PPTX
Elastic Stack Introduction
PDF
Reliable Event Delivery in Apache Kafka Based on Retry Policy and Dead Letter...
PDF
Java Code Review Checklist
PPTX
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
PDF
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
PDF
Apache Spark Listeners: A Crash Course in Fast, Easy Monitoring
PDF
Introduction to Apache Spark
PDF
Running Apache Spark on Kubernetes: Best Practices and Pitfalls
PDF
Parquet performance tuning: the missing guide
PDF
Trino: A Ludicrously Fast Query Engine - Pulsar Summit NA 2021
[Meetup] a successful migration from elastic search to clickhouse
MySQL 8.0 EXPLAIN ANALYZE
Reactive programming
Apache Spark Streaming in K8s with ArgoCD & Spark Operator
LINE's messaging service architecture underlying more than 200 million monthl...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Introduction to Apache Spark
Scalability, Availability & Stability Patterns
DPDK & Layer 4 Packet Processing
Real Time UI with Apache Kafka Streaming Analytics of Fast Data and Server Push
Elastic Stack Introduction
Reliable Event Delivery in Apache Kafka Based on Retry Policy and Dead Letter...
Java Code Review Checklist
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
The Rise of ZStandard: Apache Spark/Parquet/ORC/Avro
Apache Spark Listeners: A Crash Course in Fast, Easy Monitoring
Introduction to Apache Spark
Running Apache Spark on Kubernetes: Best Practices and Pitfalls
Parquet performance tuning: the missing guide
Trino: A Ludicrously Fast Query Engine - Pulsar Summit NA 2021
Ad

Viewers also liked (20)

PDF
PostgreSQL: meet your queue
PDF
Rabbitmq Boot System
PDF
Skytools: PgQ Queues and applications
PDF
Taming the rabbit
PDF
Implementeer een Service Orchestrated Architecture
PPTX
Morning at Lohika - Spring Boot Kotlin, a match made in Heaven
PPT
Introduction to Law & Government
PPTX
Microservices With SenecaJS
PPTX
Microservices with SenecaJS (part 2)
PDF
Tutorial su JMS (Java Message Service)
PDF
Fi fo euc 2014
PDF
The Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
PDF
BayLISA meetup: 8/16/12
PDF
Chef on SmartOS
PDF
SmartOS ZFS Architecture
PPTX
RabbitMq
PDF
Где живут Ваши объявления / Тюрин Михаил (Avito)
PDF
OpenStack on SmartOS
PDF
JMS - Java Messaging Service
PostgreSQL: meet your queue
Rabbitmq Boot System
Skytools: PgQ Queues and applications
Taming the rabbit
Implementeer een Service Orchestrated Architecture
Morning at Lohika - Spring Boot Kotlin, a match made in Heaven
Introduction to Law & Government
Microservices With SenecaJS
Microservices with SenecaJS (part 2)
Tutorial su JMS (Java Message Service)
Fi fo euc 2014
The Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
BayLISA meetup: 8/16/12
Chef on SmartOS
SmartOS ZFS Architecture
RabbitMq
Где живут Ваши объявления / Тюрин Михаил (Avito)
OpenStack on SmartOS
JMS - Java Messaging Service
Ad

Similar to Integrating PostgreSql with RabbitMQ (20)

PPTX
Picking a message queue
PDF
Follow the White Rabbit - Message Queues with PHP
PDF
Messaging with RabbitMQ and AMQP
PDF
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
PDF
The Future of Messaging: RabbitMQ and AMQP
PDF
Multi-language/multi-OS communication using RabbitMQ
PDF
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de Bruin
PDF
Down the RabbitMQ Hole
PDF
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
PPTX
The RabbitMQ Message Broker
PPTX
Spring RabbitMQ
PDF
Ruby Microservices with RabbitMQ
PPTX
Apache Kafka
PPTX
Spring RabbitMQ
PDF
Devfest uk & ireland using apache nifi with apache pulsar for fast data on-r...
PPTX
RabbitMQ and AMQP with .net client library
ZIP
Elegant Systems Integration w/ Apache Camel
PDF
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
PDF
Using the FLiPN Stack for Edge AI (Flink, NiFi, Pulsar)
PDF
Picking a message queue
Follow the White Rabbit - Message Queues with PHP
Messaging with RabbitMQ and AMQP
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
The Future of Messaging: RabbitMQ and AMQP
Multi-language/multi-OS communication using RabbitMQ
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de Bruin
Down the RabbitMQ Hole
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
The RabbitMQ Message Broker
Spring RabbitMQ
Ruby Microservices with RabbitMQ
Apache Kafka
Spring RabbitMQ
Devfest uk & ireland using apache nifi with apache pulsar for fast data on-r...
RabbitMQ and AMQP with .net client library
Elegant Systems Integration w/ Apache Camel
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Using the FLiPN Stack for Edge AI (Flink, NiFi, Pulsar)

Recently uploaded (20)

PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PPTX
Supervised vs unsupervised machine learning algorithms
PPTX
Business Acumen Training GuidePresentation.pptx
PPT
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PDF
Lecture1 pattern recognition............
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
Computer network topology notes for revision
PPTX
Major-Components-ofNKJNNKNKNKNKronment.pptx
PDF
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PDF
Launch Your Data Science Career in Kochi – 2025
PPTX
1_Introduction to advance data techniques.pptx
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
PDF
Clinical guidelines as a resource for EBP(1).pdf
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
IBA_Chapter_11_Slides_Final_Accessible.pptx
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Supervised vs unsupervised machine learning algorithms
Business Acumen Training GuidePresentation.pptx
Chapter 2 METAL FORMINGhhhhhhhjjjjmmmmmmmmm
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
Lecture1 pattern recognition............
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
climate analysis of Dhaka ,Banglades.pptx
Computer network topology notes for revision
Major-Components-ofNKJNNKNKNKNKronment.pptx
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
Introduction-to-Cloud-ComputingFinal.pptx
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
Launch Your Data Science Career in Kochi – 2025
1_Introduction to advance data techniques.pptx
Galatica Smart Energy Infrastructure Startup Pitch Deck
Clinical guidelines as a resource for EBP(1).pdf

Integrating PostgreSql with RabbitMQ