SlideShare a Scribd company logo
PostgreSQL:
meet your Queue



    / Presentation / Theo Schlossnagle



                                         1
PostgreSQL is Awesome



    •   Fast.

    •   Extensible.

    •   Tablespaces.

    •   Robust data types.

    •   Partitioning (albeit fake).

    •   Partial and functional indexes.

    •   Extremely supportive community.

    •   Extremely compliant with database standards.




                                                       2
PostgreSQL is not the “world”




     •   Inevitably, we must interact with the rest of the world.

     •   “non-SQL” components:

         •   nosql systems

         •   caching systems

         •   search systems (solr/lucene)

         •   management processes




                                                                    3
Appropiare Typicalis



     •   Enforce in the application:

         •   the application code that updates the price or description of a
             product in the products table;

         •   the application submits the updates to the search index system.

     •   The flaw:

         •   psql# UPDATE products
                      SET description =
                          REPLACE(description, ‘behaviour’, ‘behavior’);

         •   Administrative fixes like that require out-of-band dependency
             handling.




                                                                               4
A Solution


     •   Ideally, the database would notify all of these systems.

     •   The most common case I see: memcached.

         •   app: pull from memcached user::jesus@omniti.com
                  if not found:
                    select * from users where email=‘jesus@omniti.com‘
                    put row in memcached at user::jesus@omniti.com

         •   app: update users set mood=‘happy‘
                   where email=‘jesus@omniti.com‘
                  (a) purge memcached record
                  (b) get full row and replace in memcached

         •   hence: pgmemcache

     •   Problem:

         •   need a Postgres module for each remote component




                                                                         5
Enter Queueing



    •   Queueing?

        •   A generic message bus that allows PostgreSQL to communicate
            with other components in the architecture.

        •   Enter AMQP: “Advanced Message Queueing Protocol”

            •   Why not STOMP?

            •   Why not Starling?

            •   AMQP has been around the block, and the specification is quite
                complete.

            •   Almost every “real” message broker implementation supports
                AMQP




                                                                                 6
Setups: Installing



         •   svn export 
              https://labs.omniti.com/pgtreats/trunk/contrib/pg_amqp

         •   cd pg_amqp

         •   make USE_PGXS=1

         •   make install

         •   add to postgresql.conf:
             shared_preload_libraries = 'pg_amqp.so'

         •   (re)start postgres

         •   load the pg_amqp.sql file into your database.




                                                                       7
Setup: configuring your broker




      INSERT INTO amqp.broker (host,port,vhost,username,password)
          VALUES (‘localhost’,5672,NULL,‘guest’,‘guest’)
       RETURNING broker_id




                                                                    8
Setup: declaring an exchange




     •   This can often be done outside of the AMQP client

         •   using an AMQP management process
             (that is just, in fact, an AMQP client)

     •   Often, another component has already created the exchange.

     •   If you really need to do it within PostgreSQL:

         SELECT amqp.declare_exchange(broker_id,
                            exchange_name, exchange_type,
                            passive, durable, auto_delete)




                                                                      9
Usage: sending messages




    •   How do I connect?

        •   It’s implicit... you don’t need to.

    •   How do I disconnect?

        •   Broker connections are cached and live across transactions.

        •   If you want to explicitly disconnect:

            SELECT amqp.disconnect(broker_id);




                                                                          10
Usage: sending messages for real



     •   Sending messages as a part of my transaction:

         SELECT amqp.publish(broker_id, exchange, routing_key, message);

         •   This will publish the “message” over the specified “exchange” using
             the specified “routing_key,” but only on transaction commit within
             Postgres.



     •   Sending messages NOW:

         SELECT amqp.autonomous_publish(broker_id, exchange,
                                        routing_key, message);

         •   Publish the same message, but do it immediately.




                                                                                   11
A dark side: unsafe? WTF?




    •   Currently, pg_amqp uses the AMQP 0.8 specification.

    •   The AMQP 1.0 specification introduces formal 2PC.

    •   It is possible in the current implementation to have AMQP transaction
        fail when we commit it (in postgres’s commit txn hook) in a fashion
        that we cannot act on. Ouch.

    •   This only happens when the AMQP broker crashes between the last
        in-transaction publish call and the COMMIT on the database side.

    •   Once RabbitMQ supports AMQP 1.0, I’ll update the driver to use 2PC.




                                                                                12
Thank you for listening.
https://labs.omniti.com/pgtreats/trunk/contrib/pg_amqp/




                 / Presentation



                                                          13
Ad

Recommended

Integrating PostgreSql with RabbitMQ
Integrating PostgreSql with RabbitMQ
Gavin Roy
 
Noit ocon-2010
Noit ocon-2010
Theo Schlossnagle
 
High powered messaging with RabbitMQ
High powered messaging with RabbitMQ
James Carr
 
The Future of Messaging: RabbitMQ and AMQP
The Future of Messaging: RabbitMQ and AMQP
Eberhard Wolff
 
RabbitMQ
RabbitMQ
Lenz Gschwendtner
 
Spring RabbitMQ
Spring RabbitMQ
Martin Toshev
 
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
Tanya Denisyuk
 
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
JAX London
 
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
James Titcumb
 
Dissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal Architecture
Alvaro Videla
 
Spring RabbitMQ
Spring RabbitMQ
Martin Toshev
 
Scaling applications with RabbitMQ at SunshinePHP
Scaling applications with RabbitMQ at SunshinePHP
Alvaro Videla
 
Troubleshooting RabbitMQ and services that use it
Troubleshooting RabbitMQ and services that use it
Michael Klishin
 
Messaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQP
Eberhard Wolff
 
Apache James/Hupa & GWT
Apache James/Hupa & GWT
Manuel Carrasco Moñino
 
Messaging with amqp and rabbitmq
Messaging with amqp and rabbitmq
Selasie Hanson
 
Apache james more than emails in the cloud
Apache james more than emails in the cloud
Ioan Eugen Stan
 
Rabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging Patterns
Javier Arias Losada
 
A Closer Look at RabbitMQ
A Closer Look at RabbitMQ
Kyumars Sheykh Esmaili
 
Lessons from managing a Pulsar cluster (Nutanix)
Lessons from managing a Pulsar cluster (Nutanix)
StreamNative
 
Scaling PostgreSQL with Skytools
Scaling PostgreSQL with Skytools
Gavin Roy
 
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
StreamNative
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPC
Max Alexejev
 
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Chen-en Lu
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues
Naukri.com
 
Configuration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needs
SaltStack
 
RabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka Part II Webinar
Erlang Solutions
 
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
StreamNative
 
Skytools: PgQ Queues and applications
Skytools: PgQ Queues and applications
elliando dias
 
Rabbitmq Boot System
Rabbitmq Boot System
Alvaro Videla
 

More Related Content

What's hot (20)

Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
James Titcumb
 
Dissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal Architecture
Alvaro Videla
 
Spring RabbitMQ
Spring RabbitMQ
Martin Toshev
 
Scaling applications with RabbitMQ at SunshinePHP
Scaling applications with RabbitMQ at SunshinePHP
Alvaro Videla
 
Troubleshooting RabbitMQ and services that use it
Troubleshooting RabbitMQ and services that use it
Michael Klishin
 
Messaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQP
Eberhard Wolff
 
Apache James/Hupa & GWT
Apache James/Hupa & GWT
Manuel Carrasco Moñino
 
Messaging with amqp and rabbitmq
Messaging with amqp and rabbitmq
Selasie Hanson
 
Apache james more than emails in the cloud
Apache james more than emails in the cloud
Ioan Eugen Stan
 
Rabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging Patterns
Javier Arias Losada
 
A Closer Look at RabbitMQ
A Closer Look at RabbitMQ
Kyumars Sheykh Esmaili
 
Lessons from managing a Pulsar cluster (Nutanix)
Lessons from managing a Pulsar cluster (Nutanix)
StreamNative
 
Scaling PostgreSQL with Skytools
Scaling PostgreSQL with Skytools
Gavin Roy
 
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
StreamNative
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPC
Max Alexejev
 
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Chen-en Lu
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues
Naukri.com
 
Configuration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needs
SaltStack
 
RabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka Part II Webinar
Erlang Solutions
 
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
StreamNative
 
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
James Titcumb
 
Dissecting the rabbit: RabbitMQ Internal Architecture
Dissecting the rabbit: RabbitMQ Internal Architecture
Alvaro Videla
 
Scaling applications with RabbitMQ at SunshinePHP
Scaling applications with RabbitMQ at SunshinePHP
Alvaro Videla
 
Troubleshooting RabbitMQ and services that use it
Troubleshooting RabbitMQ and services that use it
Michael Klishin
 
Messaging with RabbitMQ and AMQP
Messaging with RabbitMQ and AMQP
Eberhard Wolff
 
Messaging with amqp and rabbitmq
Messaging with amqp and rabbitmq
Selasie Hanson
 
Apache james more than emails in the cloud
Apache james more than emails in the cloud
Ioan Eugen Stan
 
Rabbitmq, amqp Intro - Messaging Patterns
Rabbitmq, amqp Intro - Messaging Patterns
Javier Arias Losada
 
Lessons from managing a Pulsar cluster (Nutanix)
Lessons from managing a Pulsar cluster (Nutanix)
StreamNative
 
Scaling PostgreSQL with Skytools
Scaling PostgreSQL with Skytools
Gavin Roy
 
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
What's New in Apache Pulsar 2.9- Pulsar Summit Asia 2021
StreamNative
 
Modern Distributed Messaging and RPC
Modern Distributed Messaging and RPC
Max Alexejev
 
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Apache Kafka: A high-throughput distributed messaging system @ JCConf 2014
Chen-en Lu
 
[@NaukriEngineering] Messaging Queues
[@NaukriEngineering] Messaging Queues
Naukri.com
 
Configuration Management - Finding the tool to fit your needs
Configuration Management - Finding the tool to fit your needs
SaltStack
 
RabbitMQ vs Apache Kafka Part II Webinar
RabbitMQ vs Apache Kafka Part II Webinar
Erlang Solutions
 
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
Using Apache Pulsar as a Modern, Scalable, High Performing JMS Platform - Pus...
StreamNative
 

Viewers also liked (17)

Skytools: PgQ Queues and applications
Skytools: PgQ Queues and applications
elliando dias
 
Rabbitmq Boot System
Rabbitmq Boot System
Alvaro Videla
 
Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)
Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)
Ontico
 
Pg amqp
Pg amqp
Command Prompt., Inc
 
Индексы в MSSQL: принципы работы и способы оптимизации
Индексы в MSSQL: принципы работы и способы оптимизации
Alexander Byndyu
 
BayLISA meetup: 8/16/12
BayLISA meetup: 8/16/12
bcantrill
 
Fi fo euc 2014
Fi fo euc 2014
Licenser
 
The Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
The Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
Chef Software, Inc.
 
Chef on SmartOS
Chef on SmartOS
Eric Saxby
 
SmartOS ZFS Architecture
SmartOS ZFS Architecture
Bill Pijewski
 
Taming the rabbit
Taming the rabbit
Alvaro Videla
 
OpenStack on SmartOS
OpenStack on SmartOS
Daniele Stroppa
 
PostgreSQL в высоконагруженных проектах
PostgreSQL в высоконагруженных проектах
Alexey Vasiliev
 
Experiences porting KVM to SmartOS
Experiences porting KVM to SmartOS
bcantrill
 
Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)
Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)
Ontico
 
SmartOS Primer
SmartOS Primer
Daniele Stroppa
 
Steve Jobs Inspirational Quotes
Steve Jobs Inspirational Quotes
InsideView
 
Skytools: PgQ Queues and applications
Skytools: PgQ Queues and applications
elliando dias
 
Rabbitmq Boot System
Rabbitmq Boot System
Alvaro Videla
 
Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)
Использование очередей асинхронных сообщений с PostgreSQL (Илья Космодемьянский)
Ontico
 
Индексы в MSSQL: принципы работы и способы оптимизации
Индексы в MSSQL: принципы работы и способы оптимизации
Alexander Byndyu
 
BayLISA meetup: 8/16/12
BayLISA meetup: 8/16/12
bcantrill
 
Fi fo euc 2014
Fi fo euc 2014
Licenser
 
The Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
The Kitchen Cloud How To: Automating Joyent SmartMachines with Chef
Chef Software, Inc.
 
Chef on SmartOS
Chef on SmartOS
Eric Saxby
 
SmartOS ZFS Architecture
SmartOS ZFS Architecture
Bill Pijewski
 
PostgreSQL в высоконагруженных проектах
PostgreSQL в высоконагруженных проектах
Alexey Vasiliev
 
Experiences porting KVM to SmartOS
Experiences porting KVM to SmartOS
bcantrill
 
Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)
Spilo, отказоустойчивый PostgreSQL кластер / Oleksii Kliukin (Zalando SE)
Ontico
 
Steve Jobs Inspirational Quotes
Steve Jobs Inspirational Quotes
InsideView
 
Ad

Similar to PostgreSQL: meet your queue (20)

On Rabbits and Elephants
On Rabbits and Elephants
Gavin Roy
 
Life in a Queue - Using Message Queue with django
Life in a Queue - Using Message Queue with django
Tareque Hossain
 
Small Overview of Skype Database Tools
Small Overview of Skype Database Tools
elliando dias
 
Lindsay distributed geventzmq
Lindsay distributed geventzmq
Robin Xiao
 
The Art of Message Queues - TEKX
The Art of Message Queues - TEKX
Mike Willbanks
 
Building scalable flexible messaging systems using qpid
Building scalable flexible messaging systems using qpid
Jack Gibson
 
Database Tools by Skype
Database Tools by Skype
elliando dias
 
Integration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud Foundry
Joshua Long
 
The Accidental DBA
The Accidental DBA
PostgreSQL Experts, Inc.
 
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Jimmy DeadcOde
 
PHP projects beyond the LAMP stack
PHP projects beyond the LAMP stack
Codemotion
 
Evented applications with RabbitMQ and CakePHP
Evented applications with RabbitMQ and CakePHP
markstory
 
Messaging With ActiveMQ
Messaging With ActiveMQ
Bruce Snyder
 
Real time system_performance_mon
Real time system_performance_mon
Tomas Doran
 
Cosug 2012-lzy
Cosug 2012-lzy
OpenCity Community
 
Hacking on OpenStack\'s Nova source code
Hacking on OpenStack\'s Nova source code
Zhongyue Luo
 
Cooking a rabbit pie
Cooking a rabbit pie
Tomas Doran
 
Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMS
Bruce Snyder
 
IBM IMPACT 2014 AMC-1866 Introduction to IBM Messaging Capabilities
IBM IMPACT 2014 AMC-1866 Introduction to IBM Messaging Capabilities
Peter Broadhurst
 
RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009
Paolo Negri
 
On Rabbits and Elephants
On Rabbits and Elephants
Gavin Roy
 
Life in a Queue - Using Message Queue with django
Life in a Queue - Using Message Queue with django
Tareque Hossain
 
Small Overview of Skype Database Tools
Small Overview of Skype Database Tools
elliando dias
 
Lindsay distributed geventzmq
Lindsay distributed geventzmq
Robin Xiao
 
The Art of Message Queues - TEKX
The Art of Message Queues - TEKX
Mike Willbanks
 
Building scalable flexible messaging systems using qpid
Building scalable flexible messaging systems using qpid
Jack Gibson
 
Database Tools by Skype
Database Tools by Skype
elliando dias
 
Integration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud Foundry
Joshua Long
 
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Website Monitoring with Distributed Messages/Tasks Processing (AMQP & RabbitM...
Jimmy DeadcOde
 
PHP projects beyond the LAMP stack
PHP projects beyond the LAMP stack
Codemotion
 
Evented applications with RabbitMQ and CakePHP
Evented applications with RabbitMQ and CakePHP
markstory
 
Messaging With ActiveMQ
Messaging With ActiveMQ
Bruce Snyder
 
Real time system_performance_mon
Real time system_performance_mon
Tomas Doran
 
Hacking on OpenStack\'s Nova source code
Hacking on OpenStack\'s Nova source code
Zhongyue Luo
 
Cooking a rabbit pie
Cooking a rabbit pie
Tomas Doran
 
Enterprise Messaging With ActiveMQ and Spring JMS
Enterprise Messaging With ActiveMQ and Spring JMS
Bruce Snyder
 
IBM IMPACT 2014 AMC-1866 Introduction to IBM Messaging Capabilities
IBM IMPACT 2014 AMC-1866 Introduction to IBM Messaging Capabilities
Peter Broadhurst
 
RabbitMQ with python and ruby RuPy 2009
RabbitMQ with python and ruby RuPy 2009
Paolo Negri
 
Ad

More from Theo Schlossnagle (20)

Adding Simplicity to Complexity
Adding Simplicity to Complexity
Theo Schlossnagle
 
Put Some SRE in Your Shipped Software
Put Some SRE in Your Shipped Software
Theo Schlossnagle
 
Monitoring 101
Monitoring 101
Theo Schlossnagle
 
Distributed Systems - Like It Or Not
Distributed Systems - Like It Or Not
Theo Schlossnagle
 
Applying SRE techniques to micro service design
Applying SRE techniques to micro service design
Theo Schlossnagle
 
Craftsmanship
Craftsmanship
Theo Schlossnagle
 
SRECon Coherent Performance
SRECon Coherent Performance
Theo Schlossnagle
 
Commandments of scale
Commandments of scale
Theo Schlossnagle
 
Adaptive availability
Adaptive availability
Theo Schlossnagle
 
Project reality
Project reality
Theo Schlossnagle
 
Monitoring the #DevOps way
Monitoring the #DevOps way
Theo Schlossnagle
 
Operational Software Design
Operational Software Design
Theo Schlossnagle
 
A Coherent Discussion About Performance
A Coherent Discussion About Performance
Theo Schlossnagle
 
The math behind big systems analysis.
The math behind big systems analysis.
Theo Schlossnagle
 
Understanding Slowness
Understanding Slowness
Theo Schlossnagle
 
OmniOS Motivation and Design ~ LISA 2012
OmniOS Motivation and Design ~ LISA 2012
Theo Schlossnagle
 
Monitoring and observability
Monitoring and observability
Theo Schlossnagle
 
Omnios and unix
Omnios and unix
Theo Schlossnagle
 
Monitoring and observability
Monitoring and observability
Theo Schlossnagle
 
Xtreme Deployment
Xtreme Deployment
Theo Schlossnagle
 

Recently uploaded (20)

FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 

PostgreSQL: meet your queue

  • 1. PostgreSQL: meet your Queue / Presentation / Theo Schlossnagle 1
  • 2. PostgreSQL is Awesome • Fast. • Extensible. • Tablespaces. • Robust data types. • Partitioning (albeit fake). • Partial and functional indexes. • Extremely supportive community. • Extremely compliant with database standards. 2
  • 3. PostgreSQL is not the “world” • Inevitably, we must interact with the rest of the world. • “non-SQL” components: • nosql systems • caching systems • search systems (solr/lucene) • management processes 3
  • 4. Appropiare Typicalis • Enforce in the application: • the application code that updates the price or description of a product in the products table; • the application submits the updates to the search index system. • The flaw: • psql# UPDATE products SET description = REPLACE(description, ‘behaviour’, ‘behavior’); • Administrative fixes like that require out-of-band dependency handling. 4
  • 5. A Solution • Ideally, the database would notify all of these systems. • The most common case I see: memcached. • app: pull from memcached user::[email protected] if not found: select * from users where email=‘[email protected]‘ put row in memcached at user::[email protected] • app: update users set mood=‘happy‘ where email=‘[email protected]‘ (a) purge memcached record (b) get full row and replace in memcached • hence: pgmemcache • Problem: • need a Postgres module for each remote component 5
  • 6. Enter Queueing • Queueing? • A generic message bus that allows PostgreSQL to communicate with other components in the architecture. • Enter AMQP: “Advanced Message Queueing Protocol” • Why not STOMP? • Why not Starling? • AMQP has been around the block, and the specification is quite complete. • Almost every “real” message broker implementation supports AMQP 6
  • 7. Setups: Installing • svn export https://labs.omniti.com/pgtreats/trunk/contrib/pg_amqp • cd pg_amqp • make USE_PGXS=1 • make install • add to postgresql.conf: shared_preload_libraries = 'pg_amqp.so' • (re)start postgres • load the pg_amqp.sql file into your database. 7
  • 8. Setup: configuring your broker INSERT INTO amqp.broker (host,port,vhost,username,password) VALUES (‘localhost’,5672,NULL,‘guest’,‘guest’) RETURNING broker_id 8
  • 9. Setup: declaring an exchange • This can often be done outside of the AMQP client • using an AMQP management process (that is just, in fact, an AMQP client) • Often, another component has already created the exchange. • If you really need to do it within PostgreSQL: SELECT amqp.declare_exchange(broker_id, exchange_name, exchange_type, passive, durable, auto_delete) 9
  • 10. Usage: sending messages • How do I connect? • It’s implicit... you don’t need to. • How do I disconnect? • Broker connections are cached and live across transactions. • If you want to explicitly disconnect: SELECT amqp.disconnect(broker_id); 10
  • 11. Usage: sending messages for real • Sending messages as a part of my transaction: SELECT amqp.publish(broker_id, exchange, routing_key, message); • This will publish the “message” over the specified “exchange” using the specified “routing_key,” but only on transaction commit within Postgres. • Sending messages NOW: SELECT amqp.autonomous_publish(broker_id, exchange, routing_key, message); • Publish the same message, but do it immediately. 11
  • 12. A dark side: unsafe? WTF? • Currently, pg_amqp uses the AMQP 0.8 specification. • The AMQP 1.0 specification introduces formal 2PC. • It is possible in the current implementation to have AMQP transaction fail when we commit it (in postgres’s commit txn hook) in a fashion that we cannot act on. Ouch. • This only happens when the AMQP broker crashes between the last in-transaction publish call and the COMMIT on the database side. • Once RabbitMQ supports AMQP 1.0, I’ll update the driver to use 2PC. 12
  • 13. Thank you for listening. https://labs.omniti.com/pgtreats/trunk/contrib/pg_amqp/ / Presentation 13