Code Monkey home page Code Monkey logo

pgsql-listen-exchange's Introduction

PostgreSQL LISTEN Exchange

A RabbitMQ exchange type that translates PostgreSQL NOTIFY messages to AMQP messages and publishes them to bound queues. The PostgreSQL NOTIFY message channel is used as the routing key for the message using direct exchange style routing mechanics.

Example

To publish Postgres notifications as AMQP messages into queues bound to a x-pgsql-listen exchange with a binding key of test, run the following command in psql:

postgres=# NOTIFY test, 'This is a test';

Installation

Extract the contents of the release zip file into your RabbitMQ plugins directory. Once extracted, run rabbitmq-plugins enable pgsql_listen_exchange.

Configuration

Argument Based Configuration

To connect to PostgreSQL using something other than the default pgsql://postgres@localhost:5432/postgres connection, you can add arguments when declaring the exchange:

Setting Description Data Type
x-host The PostgreSQL server hostname String
x-port The port to connect on Number
x-dbname The database name to connect to String
x-user The user to connect as String
x-password The password to use when connecting String

Policy Based Configuration

To apply configuration via a policy, the following settings are available:

Setting Description Data Type
pgsql-listen-host The PostgreSQL server hostname String
pgsql-listen-port The port to connect on Number
pgsql-listen-dbname The database name to connect to String
pgsql-listen-user The user to connect as String
pgsql-listen-password The password to use when connecting String

Configuration in rabbitmq.config

You can also change the default connection values in the rabbitmq.config file:

Setting Description Data Type Default Value
host The PostgreSQL server hostname list "localhost"
port The port to connect on integer 5432
dbname The database name to connect to list "postgres"
user The user to connect as list "postgres"
password The password to use when connecting list ""

Example rabbitmq.config

[{pgsql_listen_exchange,
  [
    {host, "localhost"},
    {port, 5432},
    {dbname, "postgres"},
    {user, "postgres"},
    {password, ""}
  ]}
].

Message Properties

The exchange will automatically add the following properties to messages:

Property Value
app_id pgsql-listen-exchange
headers See "Headers Properties Values" table below
timestamp The UNIX epoch timestamp of the publishing server

Headers Property Values

The following table details the values of the headers property that is set on each message.

Key Value
pgsql-channel The PostgreSQL notification channel
pgsql-server The host and port of the PostgreSQL server
source-exchange The pgsql-listen-exchange that the notification was received by

Specifying Other Properties

In addition to the automatically set message properties, the exchange can set configured message properties. To set one of the supported message properties, specify the property name and value when binding to the exchange. For example, to set the content_type property, specify content_type and the value it should be set to when binding a queue to the exchange. The following message properties are supported:

Property Data Type
content_encoding String
content_type String
delivery_mode Number
priority Number
reply_to String
type String

Building

Steps to custom build a version of the pgsql-listen-exchange plugin:

git clone https://github.com/rabbitmq/rabbitmq-public-umbrella
cd rabbitmq-public-umbrella
make co
make BRANCH=rabbitmq_v3_5_4 up_c
git clone https://github.com/gmr/epgsql-wrapper.git
git clone https://github.com/aweber/pgsql-listen-exchange.git
cd rabbitmq-pgsql-listen-exchange
make

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.