root/trunk/contrib/pg_amqp/pg_amqp.sql

Revision 73, 2.2 kB (checked in by jesus, 4 years ago)

exchange declare, lots of fix up and autonomous publishing + comments on functions.

Line 
1 BEGIN;
2 create schema amqp;
3
4 create function amqp.exchange_declare(integer, varchar, varchar, boolean, boolean, boolean)
5 returns boolean as 'pg_amqp.so', 'pg_amqp_exchange_declare'
6 language C immutable;
7
8 comment on function amqp.exchange_declare(integer, varchar, varchar, boolean, boolean, boolean) is
9 'Declares a exchange (broker_id, exchange_name, exchange_type, passive, durable, auto_delete)
10 auto_delete should be set to false as unexpected errors can cause disconnect/reconnect which
11 would trigger the auto deletion of the exchange.';
12
13 create function amqp.publish(integer, varchar, varchar, varchar)
14 returns boolean as 'pg_amqp.so', 'pg_amqp_publish'
15 language C immutable;
16
17 comment on function amqp.publish(integer, varchar, varchar, varchar) is
18 'Publishes a message (broker_id, exchange, routing_key, message).  The message will only
19 be published if the containing PostgreSQL transaction successfully commits.  Under certain
20 circumstances, the AMQP commit might fail.  In this case, a WARNING is emitted.
21
22 Publish returns a boolean indicating if the publish command was successful.  Note that as
23 AMQP publish is asynchronous, you may find out later it was unsuccessful.';
24
25 create function amqp.autonomous_publish(integer, varchar, varchar, varchar)
26 returns boolean as 'pg_amqp.so', 'pg_amqp_autonomous_publish'
27 language C immutable;
28
29 comment on function amqp.autonomous_publish(integer, varchar, varchar, varchar) is
30 'Works as amqp.publish does, but the message is published immediately irrespective of the
31 current transaction state.  PostgreSQL commit and rollback at a later point will have no
32 effect on this message being sent to AMQP.';
33
34 create function amqp.disconnect(integer)
35 returns void as 'pg_amqp.so', 'pg_amqp_disconnect'
36 language C immutable strict;
37
38 comment on function amqp.disconnect(integer) is
39 'Explicitly disconnect the specified (broker_id) if it is current connected. Broker
40 connections, once established, live until the PostgreSQL backend terminated.  This
41 allows for more precise control over that.
42 select amqp.disconnect(broker_id) from amqp.broker
43 will disconnect any brokers that may be connected.';
44
45 create table amqp.broker (
46   broker_id serial not null primary key,
47   host text,
48   port integer,
49   vhost text,
50   username text,
51   password text
52 );
53
54 COMMIT;
Note: See TracBrowser for help on using the browser.