Skip to content

Instantly share code, notes, and snippets.

@redrick
Last active February 24, 2017 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redrick/9c6c382e71468c0e5c558e0a4622e646 to your computer and use it in GitHub Desktop.
Save redrick/9c6c382e71468c0e5c558e0a4622e646 to your computer and use it in GitHub Desktop.
RabbitMQ + PostgreSQL

install rabbitMQ:

brew install rabbitmq
brew services start rabbitmq

web interface

http://localhost:15672/
name: guest
pwd: guest

install PG extension:

git clone https://github.com/omniti-labs/pg_amqp.git
make
make install

in every PG DB we want to use migrate:

CREATE EXTENSION amqp;

insert your login infromation (these are default):

INSERT INTO amqp.broker (host, port, username, password) VALUES ('127.0.0.1', '5672', 'guest', 'guest');

lookup broker id in amqp.broker table (the one you just inserted):

SELECT * FROM amqp.broker;

now you can send messages through amqp from PG like this:

SELECT amqp.publish(1, '', 'hello', 'Ahoj');

params of publish call as they appear:

1 -> broker id from previous step

'' -> leave blank for default AMQP exchange

'hello' -> name of the queue you are posting to

'Ahoj' -> payload (could be json and so according to PG specs)

To listen have a look at:

https://github.com/redrick/rabbitmq_test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment