-
Notifications
You must be signed in to change notification settings - Fork 0
RabbitMQ
Beau Barker edited this page Aug 3, 2025
·
38 revisions
compose.yaml
services:
rabbitmq:
image: rabbitmq:3
environment:
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: "-rabbit channel_max 0"Clone the repository:
git clone https://github.com/omniti-labs/pg_amqp postgres/pg_amqpInstall the extension:
postgres/Dockerfile
RUN apt-get update && apt-get install -y \
build-essential \
postgresql-server-dev-17
# pg_amqp - Used by api schema
COPY ./pg_amqp /pg_amqp
WORKDIR /pg_amqp
RUN make
RUN make install
WORKDIR /var/lib/postgresqlYou may need to fix "implicit int" errors in pg_amqp, which were reported here, and fixed but not yet merged.
Build Postgres:
docker compose build postgresAdd this to a migration file:
postgres/migrations/01-extensions.sql
-- amqp extension for rabbitmq connection
create extension amqp;
⚠️ Do not wrap this file in aBEGIN/COMMITblock —create extensionis non-transactional.
Add to a migration file:
postgres/migrations/03-create_api_schema.sql
begin;
create table api.task (
id serial primary key,
name text not null
);
create function api.task_updated() returns void
language plpgsql as $$
begin
perform amqp.publish(1, 'amq.topic', 'tasks', json_build_object('event', 'task_updated', 'command', command)::text);
end;
$$;
create trigger task_updated
before update on api.task
for each row execute procedure api.task_updated();
commit;bin/postgres migrate