{"id":42148017,"url":"https://github.com/peter-mount/notify-rabbit","last_synced_at":"2026-01-26T18:00:53.706Z","repository":{"id":85761321,"uuid":"81370113","full_name":"peter-mount/notify-rabbit","owner":"peter-mount","description":"A docker application that allows PostgreSQL to send messages to RabbitMQ","archived":false,"fork":false,"pushed_at":"2017-02-08T20:23:36.000Z","size":7,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-06T21:38:32.321Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peter-mount.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-02-08T19:58:08.000Z","updated_at":"2024-02-11T01:58:08.000Z","dependencies_parsed_at":"2023-05-04T17:46:26.273Z","dependency_job_id":null,"html_url":"https://github.com/peter-mount/notify-rabbit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/peter-mount/notify-rabbit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-mount%2Fnotify-rabbit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-mount%2Fnotify-rabbit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-mount%2Fnotify-rabbit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-mount%2Fnotify-rabbit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peter-mount","download_url":"https://codeload.github.com/peter-mount/notify-rabbit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-mount%2Fnotify-rabbit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28784093,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-26T18:00:23.689Z","updated_at":"2026-01-26T18:00:53.695Z","avatar_url":"https://github.com/peter-mount.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# notify-rabbit\n## Introduction\nThis is a simple nodejs application that allows PostgreSQL to send messages to a RabbitMQ server using the notify command.\n\nFor example, in SQL you can issue one of the following commands:\n\n```\nNOTIFY queue, 'some message';\n\nSELECT pg_notify('queue','some message');\n```\n\nThis application will then immediately send a message to a RabbitMQ topic with that message to a configured routing key.\nYou can then have an application listen for messages with that key and process those events immediately.\n\n## Configuration\n\nYou need to provide a config.yaml file containing details about your database - a template is provided in the repository.\n\nIt consists of three sections:\n\n### databases\nThis section contains connection details to connect to your databases:\n\n```\ndatabases:\n    testDB:\n        enabled: true\n        host: localhost\n        port: 5432\n        database: postgres\n        user: postgres\n        password: postgres\n        ssl: false\n```\n\nHere we have just one database configured called testDB which will be referred to later.\n\n### rabbit\nThis section defines details of the rabbitmq instances you want to connect to.\nIt simply consists of a name for the instance and the connection URI to connect to it.\n\n```\nrabbit:\n    testRabbit: amqp://guest:password@localhost\n```\n\nNote: You can put an IP address here instead of the hostname.\nIf it's an IPv6 address then wrap it within a pair of [ ].\n\n### notify\nThis section defines which databases you want to listen to for notifications.\nYou usually have one entry per database (but you are not limited to this).\n\n#### Simple messages\n\n```\nnotify:\n    -\n        enabled: true\n        database: testdb\n        name: rabbit\n        handlers:\n            rabbit:\n                instance: testRabbit\n                key: job.status\n```\n\nHere we are telling the application to listen for notifications sent to the 'rabbit' queue on the testdb database.\nAll messages received would be sent as-is to the testRabbit RabbitMQ instance with the routing key 'job.status'.\n\nThen from PostgreSQL you can use:\n\n```\nSELECT pg_notify('rabbit','My message');\n```\n\nto send the message.\n\n#### Set the routing key in PostgreSQL\n\nThis is a simple case, you can allow PostgreSQL to define the routing key:\n\n```\nnotify:\n    -\n        enabled: true\n        database: testdb\n        name: rabbit\n        json: true\n        handlers:\n            rabbit:\n                instance: testRabbit\n                routingKey: key\n                payload: body\n```\n\nHere we are telling the application to expect a JSON object from PostgreSQL with two properties.\n* \"key\" will contain the routing key to use\n* \"body\" will contain the message to send.\n\n```\nSELECT pg_notify('rabbit','{\"key\":\"job.status\",\"body\": \"My message\"}');\n```\n\nNote: \"payload\" is optional here. If absent then the original message will be sent including the routing key etc.\n\n## Running\nTo run first create a config.yaml file with your configuration then run:\n```\ndocker run -d -v $(pwd)/config.yaml:/opt/config.yaml area51/node-notify\n```\n\n## Online examples\n* [Area51 Job Status](http://area51.onl/status/job/) is a web page showing various job statuses. It connects to RabbitMQ over a websocket and receives events from a table in a PostgreSQL database. Updates are sent by a trigger in the db via RabbitMQ to the webpage.\n\n## PostgreSQL Trigger example\n\nGiven a simple table containing three columns:\n* id INTEGER\n* name NAME\n* dt TIMESTAMP\n\nWe could then create a simple trigger to send a message whenever a row is inserted or updated:\n\n```\nCREATE OR REPLACE FUNCTION notifyupdate()\nRETURNS TRIGGER AS $$\nBEGIN\n    PERFORM pg_notify('rabbit', json_build_object(\n        'key', CONCAT('table.', NEW.name),\n        'body', json_build_object(\n            'id', NEW.id,\n            'name', NEW.name,\n            'dt', to_char(NEW.dt, 'YYYY-MM-DDThh24:MI:SSZ')\n        )\n    );\n    RETURN NEW;\nEND\n$$ LANGUAGE plpgsql;\n\nCREATE TRIGGER notifystate\n    AFTER INSERT OR UPDATE ON mytable\n    FOR EACH ROW EXECUTE PROCEDURE notifyupdate();\n```\n\nNext config.yaml:\n```\nnotify:\n    -\n        enabled: true\n        database: testdb\n        name: rabbit\n        json: true\n        handlers:\n            rabbit:\n                instance: testRabbit\n                routingKey: key\n                payload: body\n```\n\nNow you'll get a copy of the id, name \u0026 dt columns in a message with it's routing key consisting of table. and the name.\n\nYou could then listen for messages with \"table.#\" or just for a specific name in that table.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-mount%2Fnotify-rabbit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeter-mount%2Fnotify-rabbit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-mount%2Fnotify-rabbit/lists"}