{"_id":"@emmadenagbe/adonis-rabbitmq","_rev":"2-0a9f8d2c8a71498bf976b03f9844822a","name":"@emmadenagbe/adonis-rabbitmq","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@emmadenagbe/adonis-rabbitmq","version":"0.1.0","keywords":["adonisjs","rabbitmq","amqp","amqplib"],"author":"","license":"MIT","_id":"@emmadenagbe/adonis-rabbitmq@0.1.0","maintainers":[{"name":"emmadenagbe","email":"emmadenagbe@gmail.com"}],"homepage":"https://github.com/emmadenagbe/adonis-rabbitmq#readme","bugs":{"url":"https://github.com/emmadenagbe/adonis-rabbitmq/issues"},"dist":{"shasum":"65992053a19c3e6d43516b867f49102ce287034f","tarball":"https://registry.npmjs.org/@emmadenagbe/adonis-rabbitmq/-/adonis-rabbitmq-0.1.0.tgz","fileCount":28,"integrity":"sha512-+fkVAIQyZLaijHXx614GRXVJp3tc8iB4G4BExalOqPEjHU0CNxqZ+Ejj3jL571AefC4sWEUJdda0eQB97DL3XA==","signatures":[{"sig":"MEUCICKohESOvzqi6ctDtuChCOkSXGoU3Vf/RfNHimuFs/2tAiEA1axoEYX+yiGrYU/2OzpnIEKHlHLxas+3evsr2Kdywdg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44728},"main":"build/index.js","type":"module","types":"build/index.d.ts","engines":{"node":">=20.6.0"},"exports":{".":"./build/index.js","./types":"./build/src/types.js","./services/main":"./build/services/main.js","./rabbitmq_provider":"./build/providers/rabbitmq_provider.js"},"gitHead":"6b946e8d1821024030257eeb317ffd11362406e2","scripts":{"lint":"eslint .","test":"node --import=ts-node-maintained/register/esm bin/test.ts","build":"tsc","clean":"del-cli build","format":"prettier --write .","prepare":"husky","release":"release-it","version":"npm run build","prebuild":"npm run clean","postbuild":"copy-files-from-to","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"emmadenagbe","email":"emmadenagbe@gmail.com"},"prettier":"@adonisjs/prettier-config","copyFiles":[{"to":"build/stubs/","from":"stubs/**/*.stub"}],"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"push":true,"tagName":"v${version}","commitMessage":"chore(release): ${version}","tagAnnotation":"v${version}","requireUpstream":true,"requireCleanWorkingDir":true},"npm":{"publish":true,"skipChecks":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"infile":"CHANGELOG.md","preset":{"name":"angular"}}}},"repository":{"url":"git+ssh://git@github.com/emmadenagbe/adonis-rabbitmq.git","type":"git"},"_npmVersion":"11.11.1","description":"RabbitMQ provider for AdonisJS 6 with resilient connections, declarative consumers, and IoC container integration","directories":{},"_nodeVersion":"25.8.2","dependencies":{"amqplib":"^0.10.4","@poppinss/utils":"^6.8.3","amqp-connection-manager":"^4.1.14"},"publishConfig":{"tag":"latest","access":"public"},"_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.7","eslint":"^9.10.0","del-cli":"^5.1.0","prettier":"^3.3.3","@swc/core":"^1.5.7","release-it":"^21.0.2","typescript":"^5.5.4","@types/node":"^22.5.5","@japa/assert":"^3.0.0","@japa/runner":"^3.1.4","@adonisjs/core":"^6.14.0","@types/amqplib":"^0.10.5","@commitlint/cli":"^21.2.2","@adonisjs/tsconfig":"^1.4.0","copy-files-from-to":"^3.11.1","ts-node-maintained":"^10.9.4","@adonisjs/eslint-config":"^2.0.0","@adonisjs/prettier-config":"^1.4.0","@commitlint/config-conventional":"^21.2.2","@release-it/conventional-changelog":"^12.0.0"},"peerDependencies":{"@adonisjs/core":"^6.2.0"},"_npmOperationalInternal":{"tmp":"tmp/adonis-rabbitmq_0.1.0_1789232758614_0.38518285311612144","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"_id":"@emmadenagbe/adonis-rabbitmq@0.1.1","bugs":{"url":"https://github.com/emmadenagbe/adonis-rabbitmq/issues"},"dist":{"shasum":"23e39710d15059ab2cdad8c33744a64898a13a23","tarball":"https://registry.npmjs.org/@emmadenagbe/adonis-rabbitmq/-/adonis-rabbitmq-0.1.1.tgz","fileCount":28,"integrity":"sha512-0VW6pS3JJrMmB6kq8dfQZsO2BqApno7rjr5LajAUFaW0nrFHNKGbmieEPpjsC1L6qbgw5+xk3o8VQTZxZI3z7g==","signatures":[{"sig":"MEQCIDYS9bFEqgS+wprdswCqjonHoXEa28Pbhj83Y0GLOEv7AiBV5cVAPcylTSLigJt7MGN8Kg1TZ7o2zuyUXtjgnExScw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC0QYHce7fJ+siUtMD9Ih+Z2d+a0TYLdsHv9d1/bNDM0AIgZYF3SUFmwY7twkJGYm14SGQqcOxTzwB4A8PT7SUNuhw="}],"unpackedSize":45154},"main":"build/index.js","name":"@emmadenagbe/adonis-rabbitmq","type":"module","types":"build/index.d.ts","author":"","engines":{"node":">=20.6.0"},"exports":{".":"./build/index.js","./types":"./build/src/types.js","./services/main":"./build/services/main.js","./rabbitmq_provider":"./build/providers/rabbitmq_provider.js"},"gitHead":"a5fb97640257ce2975235f0ca6e67908461e5e01","license":"MIT","scripts":{"lint":"eslint .","test":"node --import=ts-node-maintained/register/esm bin/test.ts","build":"tsc","clean":"del-cli build","format":"prettier --write .","prepare":"husky","release":"release-it","version":"npm run build","prebuild":"npm run clean","postbuild":"copy-files-from-to","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"version":"0.1.1","_npmUser":{"name":"emmadenagbe","email":"emmadenagbe@gmail.com"},"homepage":"https://github.com/emmadenagbe/adonis-rabbitmq#readme","keywords":["adonisjs","rabbitmq","amqp","amqplib"],"prettier":"@adonisjs/prettier-config","copyFiles":[{"to":"build/stubs/","from":"stubs/**/*.stub"}],"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"push":true,"tagName":"v${version}","commitMessage":"chore(release): ${version}","tagAnnotation":"v${version}","requireUpstream":true,"requireCleanWorkingDir":true},"npm":{"publish":true,"skipChecks":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"infile":"CHANGELOG.md","preset":{"name":"angular"}}}},"repository":{"url":"git+ssh://git@github.com/emmadenagbe/adonis-rabbitmq.git","type":"git"},"_npmVersion":"11.11.1","description":"RabbitMQ provider for AdonisJS 6 with resilient connections, declarative consumers, and IoC container integration","directories":{},"maintainers":[{"name":"emmadenagbe","email":"emmadenagbe@gmail.com"}],"_nodeVersion":"25.8.2","dependencies":{"amqplib":"^0.10.4","@poppinss/utils":"^6.8.3","amqp-connection-manager":"^4.1.14"},"publishConfig":{"tag":"latest","access":"public"},"_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.7","eslint":"^9.10.0","del-cli":"^5.1.0","prettier":"^3.3.3","@swc/core":"^1.5.7","release-it":"^21.0.2","typescript":"^5.5.4","@types/node":"^22.5.5","@japa/assert":"^3.0.0","@japa/runner":"^3.1.4","@adonisjs/core":"^6.14.0","@types/amqplib":"^0.10.5","@commitlint/cli":"^21.2.2","@adonisjs/tsconfig":"^1.4.0","copy-files-from-to":"^3.11.1","ts-node-maintained":"^10.9.4","@adonisjs/eslint-config":"^2.0.0","@adonisjs/prettier-config":"^1.4.0","@commitlint/config-conventional":"^21.2.2","@release-it/conventional-changelog":"^12.0.0"},"peerDependencies":{"@adonisjs/core":"^6.2.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/adonis-rabbitmq_0.1.1_1789234672283_0.10621723732384725"}}},"time":{"created":"2026-09-12T17:05:58.434Z","modified":"2026-09-12T17:37:52.541Z","0.1.0":"2026-09-12T17:05:58.763Z","0.1.1":"2026-09-12T17:37:52.372Z"},"bugs":{"url":"https://github.com/emmadenagbe/adonis-rabbitmq/issues"},"license":"MIT","homepage":"https://github.com/emmadenagbe/adonis-rabbitmq#readme","keywords":["adonisjs","rabbitmq","amqp","amqplib"],"repository":{"url":"git+ssh://git@github.com/emmadenagbe/adonis-rabbitmq.git","type":"git"},"description":"RabbitMQ provider for AdonisJS 6 with resilient connections, declarative consumers, and IoC container integration","maintainers":[{"name":"emmadenagbe","email":"emmadenagbe@gmail.com"}],"readme":"# @emmadenagbe/adonis-rabbitmq\n\n[![npm version](https://img.shields.io/npm/v/@emmadenagbe/adonis-rabbitmq.svg)](https://www.npmjs.com/package/@emmadenagbe/adonis-rabbitmq)\n[![checks](https://github.com/emmadenagbe/adonis-rabbitmq/actions/workflows/checks.yml/badge.svg)](https://github.com/emmadenagbe/adonis-rabbitmq/actions/workflows/checks.yml)\n[![license](https://img.shields.io/npm/l/@emmadenagbe/adonis-rabbitmq.svg)](LICENSE.md)\n\nA RabbitMQ integration for AdonisJS 6. It wraps [amqp-connection-manager](https://github.com/jwalton/node-amqp-connection-manager) so connections reconnect on their own, and plugs into AdonisJS's container so you can publish messages and write consumers the same way you'd write anything else in an Adonis app.\n\n## What you get\n\n- Publish messages and send them straight to a queue\n- Write consumers as classes with a `@consumer` decorator, resolved through the container (so `@inject` works inside them)\n- Failed messages are retried a few times, then moved to a dead-letter exchange automatically\n- Request/reply (RPC) over RabbitMQ, if you need it\n- Multiple named connections, if you talk to more than one broker\n- Priority queues and header-based routing, for when topic/direct routing isn't enough\n\n## Install\n\n```sh\nnode ace add @emmadenagbe/adonis-rabbitmq\n```\n\nThis does three things:\n\n- Creates `config/rabbitmq.ts`\n- Adds `RABBITMQ_URL` to `.env` and validates it in `env.ts`\n- Registers the provider in `adonisrc.ts`\n\nBy default it connects to `amqp://guest:guest@localhost:5672`. Change `RABBITMQ_URL` in `.env` to point at your broker.\n\n## Publishing a message\n\n```ts\nimport rabbitmq from '@emmadenagbe/adonis-rabbitmq/services/main'\n\nawait rabbitmq.publish('orders_exchange', 'order.created', { id: order.id })\n```\n\n`publish` sends to an exchange with a routing key. If you don't need an exchange, send straight to a queue instead:\n\n```ts\nawait rabbitmq.sendToQueue('orders', { id: order.id })\n```\n\nBoth return a promise that resolves once RabbitMQ has actually confirmed the message, not just when it's been sent.\n\nNote: if you write your own ace command that resolves `rabbitmq` from the container directly (rather than publishing from a controller/service, or letting a `@consumer` run via the normal boot process), add `static options = { startApp: true }` to that command. Ace doesn't fully boot the app for commands by default, so the binding won't exist yet without it — this is an AdonisJS ace thing, not specific to this package.\n\n## Writing a consumer\n\nConsumers are classes. Put them wherever you like (`app/consumers/` is a reasonable default) and decorate them with `@consumer`:\n\n```ts\n// app/consumers/orders_consumer.ts\nimport { consumer, BaseConsumer } from '@emmadenagbe/adonis-rabbitmq'\n\n@consumer({\n  queue: 'orders',\n  exchange: 'orders_exchange',\n  routingKey: 'order.created',\n})\nexport default class OrdersConsumer extends BaseConsumer<{ id: number }> {\n  async handle(payload: { id: number }) {\n    // do something with the message\n  }\n}\n```\n\nA consumer only starts listening once its file has actually been imported somewhere. The easiest way to make that happen is a preload file:\n\n```ts\n// start/rabbitmq.ts\nimport '#app/consumers/orders_consumer'\n// import every other consumer here too\n```\n\n```ts\n// adonisrc.ts\n{\n  preloads: ['./start/rabbitmq.js']\n}\n```\n\n### If handling a message fails\n\nIf `handle` throws, the message is retried automatically (3 times by default, after a short delay), and if it keeps failing it's routed to a dead-letter exchange named `<queue>.dlx` so you don't lose it. Change the retry count per consumer:\n\n```ts\n@consumer({ queue: 'orders', maxRetries: 5 })\n```\n\n## Multiple connections\n\nIf you need more than one broker (or more than one vhost), name your connections in the config file:\n\n```ts\n// config/rabbitmq.ts\nconst rabbitmqConfig = defineConfig({\n  connection: 'main',\n  connections: {\n    main: { url: env.get('RABBITMQ_URL') },\n    events: { url: env.get('EVENTS_RABBITMQ_URL') },\n  },\n})\n```\n\nThen point a publish call or a consumer at the one you want:\n\n```ts\nawait rabbitmq.publish('exchange', 'key', payload, { connection: 'events' })\n\n@consumer({ queue: 'audit', connection: 'events' })\nexport default class AuditConsumer extends BaseConsumer {}\n```\n\nLeave it out and everything uses `main`.\n\n## Request/reply (RPC)\n\nSometimes you want to send a message and wait for an answer, instead of just firing it off. `request` does that:\n\n```ts\nconst response = await rabbitmq.request('math.double', { n: 21 })\n// response is whatever the consumer replied with\n```\n\nOn the other end, a consumer replies using the raw message it was handed:\n\n```ts\n@consumer({ queue: 'math.double' })\nexport default class DoubleConsumer extends BaseConsumer<{ n: number }> {\n  async handle(payload: { n: number }, raw) {\n    await rabbitmq.reply(raw, { result: payload.n * 2 })\n  }\n}\n```\n\nIf nothing replies, `request` rejects after 30 seconds by default. Change that with `{ timeoutMs: 5000 }`.\n\n## Priority queues\n\nIf some messages should jump ahead of others in the same queue, set `maxPriority` on the consumer and a `priority` on the message:\n\n```ts\n@consumer({ queue: 'jobs', maxPriority: 10 })\nexport default class JobsConsumer extends BaseConsumer {}\n```\n\n```ts\nawait rabbitmq.sendToQueue('jobs', payload, { priority: 9 })\n```\n\n## Routing by headers instead of a routing key\n\nFor cases where a topic/direct routing key doesn't fit, you can bind a queue based on message headers instead:\n\n```ts\n@consumer({\n  queue: 'eu-orders',\n  exchange: 'orders_exchange',\n  exchangeType: 'headers',\n  headers: { region: 'eu' },\n  headersMatch: 'all', // or 'any'\n})\nexport default class EuOrdersConsumer extends BaseConsumer {}\n```\n\n```ts\nawait rabbitmq.publish('orders_exchange', '', payload, { headers: { region: 'eu' } })\n```\n\n## Testing locally\n\nA `compose.yml` is included, so you can start a broker with:\n\n```sh\ndocker compose up -d\n```\n\nThe management UI is at http://localhost:15672 (user/pass: `guest`/`guest`).\n\n## License\n\nMIT\n","readmeFilename":"README.md"}