{"id":19023090,"url":"https://github.com/platformatic/rabbitmq-hooks","last_synced_at":"2026-01-30T19:02:19.382Z","repository":{"id":232986575,"uuid":"780938890","full_name":"platformatic/rabbitmq-hooks","owner":"platformatic","description":"RabbitMQ adapter for Platformatic","archived":false,"fork":false,"pushed_at":"2026-01-24T18:41:25.000Z","size":1435,"stargazers_count":10,"open_issues_count":6,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-01-25T07:45:41.359Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/platformatic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-04-02T12:56:27.000Z","updated_at":"2026-01-24T18:41:28.000Z","dependencies_parsed_at":"2024-04-12T21:15:34.852Z","dependency_job_id":"0e8051ce-f5e8-4616-94c0-b53257b2eebf","html_url":"https://github.com/platformatic/rabbitmq-hooks","commit_stats":null,"previous_names":["platformatic/rabbitmq-hooks"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/platformatic/rabbitmq-hooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platformatic%2Frabbitmq-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platformatic%2Frabbitmq-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platformatic%2Frabbitmq-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platformatic%2Frabbitmq-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/platformatic","download_url":"https://codeload.github.com/platformatic/rabbitmq-hooks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platformatic%2Frabbitmq-hooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28917454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T16:37:38.804Z","status":"ssl_error","status_checked_at":"2026-01-30T16:37:37.878Z","response_time":66,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":"2024-11-08T20:28:41.651Z","updated_at":"2026-01-30T19:02:19.377Z","avatar_url":"https://github.com/platformatic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @platformatic/rabbitmq-hooks\n\nWrap RabbitMQ inside your application easily.\nThis assumes that you have a RabbitMQ server running, and the exchanges are already setup.\n\nThen you can:\n- Export the messages published on an exchange to a HTTP endpoint with `POST` method.\n- Publish messages to an exchange from a HTTP endpoint with a `POST` on `/publish` endpoint\n\n\n## Getting Started\n\nCreate a new Platformatic application with the RabbitMQ Hooks package using [Wattpm](https://platformatic.io/docs/wattpm):\n\n```bash\nnpx wattpm@latest create\n```\n\nAnd select `@platformatic/rabbitmq-hooks` from the list of available packages.\n\nThis application assumes that you have a RabbitMQ server running at `amqp://localhost`. A `my-exchange` exchange is created if not present.\nNow start a RabbitMQ server if not already running, for instance with docker:\n\n```bash\ndocker run -d --hostname my-rabbit --name plt-rabbit rabbitmq:3\n```\n\nThen you can run the application with `wattpm start`:\n\n```bash\n➜ wattpm start\n\n[14:10:25.128] INFO (main/91344): Starting rabbitmq-hooks plugin\n[14:10:25.197] INFO (main/91344): Connected to RabbitMQ\n[14:10:25.198] INFO (main/91344): Listening to exchange my-exchange\n[14:10:25.199] INFO (main/91344): No routing key specified\nexchange my-exchange true\n[14:10:25.213] INFO (main/91344): Registered message consumer\n[14:10:25.255] INFO (main/91344): Server listening at http://0.0.0.0:3042\n```\n\nTo test this, you can add a `out` endpoint to the app, e.g. in `routes/root` add:\n\n```javascript\nfastify.post('/out', async (request, reply) =\u003e {\n  const message = await request.body.message\n  console.log('RECEIVED MESSAGE FROM RABBITMQ')\n  console.log(message)\n})\n```\n\nThen change `.env` to use it:\n\n```bash\nPLT_SERVER_HOSTNAME=0.0.0.0\nPLT_SERVER_LOGGER_LEVEL=info\nPORT=3042\nPLT_TYPESCRIPT=false\nPLT_RABBITMQ_CONNECTION_URL=amqp://localhost\nPLT_RABBITMQ_GENERATE_EXCHANGE=true\nPLT_RABBITMQ_EXCHANGE_NAME_0=my-exchange\nPLT_RABBITMQ_TARGET_URL_0=http://localhost:3042/out\nPLT_RABBITMQ_TARGET_QUEUE_0=test-queue\n```\n\nAnd restart the application. Now you can test the application with:\n\n```bash\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"message\": \"Hello World\"}' http://localhost:3042/publish/my-exchange\n```\n\nThe message is first posted on the exchange, and then the application will post it to the `out` endpoint:\n\n```bash\n[12:35:06.204] INFO (main/321646): incoming request\n    reqId: \"52a6d8d9-8ef6-44d7-914d-a0b45a8087e5\"\n    req: {\n      \"method\": \"POST\",\n      \"url\": \"/publish/my-exchange\",\n      \"hostname\": \"localhost:3042\",\n      \"remoteAddress\": \"127.0.0.1\",\n      \"remotePort\": 59672\n    }\n[12:35:06.209] INFO (main/321646): Publishing to exchange my-exchange with routing key undefined\n[12:35:06.218] INFO (main/321646): request completed\n    reqId: \"52a6d8d9-8ef6-44d7-914d-a0b45a8087e5\"\n    res: {\n      \"statusCode\": 200\n    }\n    responseTime: 10.358657002449036\n[12:35:06.232] INFO (main/321646): incoming request\n    reqId: \"0dd754ea-38ad-47d6-ba8b-5e70f3df4732\"\n    req: {\n      \"method\": \"POST\",\n      \"url\": \"/out\",\n      \"hostname\": \"localhost:3042\",\n      \"remoteAddress\": \"127.0.0.1\",\n      \"remotePort\": 59680\n    }\nRECEIVED MESSAGE FROM RABBITMQ\n[12:35:06.235] INFO (main/321646): request completed\n    reqId: \"0dd754ea-38ad-47d6-ba8b-5e70f3df4732\"\n    res: {\n      \"statusCode\": 200\n    }\n    responseTime: 1.6560759991407394\n{\"message\":\"Hello World\"}\n```\n\n## Configuration\n\nThe plugin has a `rabbitmq` configuration object with the following, e.g.:\n\n```json\n  \"rabbitmq\": {\n    \"url\": \"{PLT_RABBITMQ_CONNECTION_URL}\",\n    \"generateExchange\": \"{PLT_RABBITMQ_GENERATE_EXCHANGE}\",\n    \"exchanges\": [\n      {\n        \"name\": \"{PLT_RABBITMQ_EXCHANGE_NAME_0}\",\n        \"targetUrl\": \"{PLT_RABBITMQ_TARGET_URL_0}\",\n        \"queue\": \"{PLT_RABBITMQ_TARGET_QUEUE_0}\"\n      }\n    ]\n  }\n```\nWith `.env`:\n\n```bash\nPLT_RABBITMQ_CONNECTION_URL=amqp://localhost\nPLT_RABBITMQ_GENERATE_EXCHANGE=true\nPLT_RABBITMQ_EXCHANGE_NAME_0=my-exchange\nPLT_RABBITMQ_TARGET_URL_0=http://localhost:3042/out\nPLT_RABBITMQ_TARGET_QUEUE_0=test-queue\n```\n\nWhere:\n- url: It's the RabbitMQ connection URL\n- generateExchange: If true, the exchange is created if not present. This is useful for testing/developing. The exchange is created as `fanout` non-durable.\n- exchanges: An array of exchanges to listen to:\n    - name: The exchange name\n    - targetUrl: The URL to post the message to. This can be a local URL, or a remote one.\n    - routingKey: [OPTIONAL} The routing key to listen to. If not specified, all messages are listened to.\n    - queue: [OPTIONAL] The queue name to listen to. If not specified, a random queue is created.\n    - durableQueue: [OPTIONAL] If true, the queue is durable. Default is false.\n    - exclusiveQueue: [OPTIONAL] If true, the queue is exclusive. Default is false.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatformatic%2Frabbitmq-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplatformatic%2Frabbitmq-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatformatic%2Frabbitmq-hooks/lists"}