{"id":13781285,"url":"https://github.com/RomainLanz/adonis-bull-queue","last_synced_at":"2025-05-11T14:34:55.061Z","repository":{"id":43185372,"uuid":"507095061","full_name":"RomainLanz/adonis-bull-queue","owner":"RomainLanz","description":"Queue system based on BullMQ for AdonisJS","archived":false,"fork":false,"pushed_at":"2024-10-02T07:45:15.000Z","size":94,"stargazers_count":163,"open_issues_count":22,"forks_count":30,"subscribers_count":4,"default_branch":"3.x","last_synced_at":"2025-05-04T00:03:03.157Z","etag":null,"topics":["adonis-framework","adonisjs","queue","queue-worker"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RomainLanz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2022-06-24T17:37:19.000Z","updated_at":"2025-04-23T14:23:33.000Z","dependencies_parsed_at":"2024-01-15T04:08:00.527Z","dependency_job_id":"e1c7dea4-a422-48c0-be1a-0d843221ae23","html_url":"https://github.com/RomainLanz/adonis-bull-queue","commit_stats":null,"previous_names":["romainlanz/adonis-bull-queue","setten-io/adonis-bull-queue"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomainLanz%2Fadonis-bull-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomainLanz%2Fadonis-bull-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomainLanz%2Fadonis-bull-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RomainLanz%2Fadonis-bull-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RomainLanz","download_url":"https://codeload.github.com/RomainLanz/adonis-bull-queue/tar.gz/refs/heads/3.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253580357,"owners_count":21930929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["adonis-framework","adonisjs","queue","queue-worker"],"created_at":"2024-08-03T18:01:24.538Z","updated_at":"2025-05-11T14:34:54.792Z","avatar_url":"https://github.com/RomainLanz.png","language":"TypeScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github-production-user-asset-6210df.s3.amazonaws.com/2793951/249391043-4d65a757-b8cb-47de-b197-774df2cf0837.png\" alt=\"@rlanz/bull-queue\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@rlanz/bull-queue\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@rlanz/bull-queue.svg?style=flat-square\" alt=\"Download\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@rlanz/bull-queue\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@rlanz/bull-queue.svg?style=flat-square\" alt=\"Version\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/@rlanz/bull-queue.svg?style=flat-square\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n`@rlanz/bull-queue` is a queue system based on [BullMQ](https://github.com/taskforcesh/bullmq)\nfor [AdonisJS](https://adonisjs.com/).\n\n\u003e [!NOTE]\n\u003e You must have a Redis server running on your machine.\n\n---\n\n## Getting Started\n\nThis package is available in the npm registry.\n\n```bash\nnode ace add @rlanz/bull-queue\n```\n\n## Usage\n\nThe `queue` service gives you access to the `dispatch` method.\nIt will dispatch the linked job to the queue with the given payload.\n\n```ts\nimport queue from '@rlanz/bull-queue/services/main';\n\nqueue.dispatch(RegisterStripeCustomer, {...});\n\n// You can also specify options for a specific job\nqueue.dispatch(RegisterStripeCustomer, {...}, {\n  queueName: 'stripe',\n});\n```\n\nYou can create a job by running `node ace make:job {job}`.\nThis will create the job within your `app/jobs` directory.\n\nThe `handle` method is what gets called when the jobs is processed while\nthe `rescue` method is called when the max attempts of the job has been reached.\n\nYou can remove the `rescue` method if you want.\n\nSince the job instance is passed to the constructor, you can easily send notifications with the `rescue` method. See [this page](https://api.docs.bullmq.io/classes/Job.html) for full documentation on the job instance.\n\n**Example job file:**\n\n```ts\n// app/jobs/register_stripe_customer.ts\nimport { Job } from '@rlanz/bull-queue'\n\ninterface RegisterStripeCustomerPayload {\n  userId: string;\n};\n\nexport default class RegisterStripeCustomer extends Job {\n  static get $$filepath() {\n    return import.meta.url\n  }\n\n  public async handle(payload: RegisterStripeCustomerPayload) {\n    // ...\n  }\n\n  /**\n   * This is an optional method that gets called if it exists when the retries has exceeded and is marked failed.\n   */\n  public async rescue(payload: RegisterStripeCustomerPayload, error: Error) {}\n}\n```\n\n#### Job Attempts\n\nBy default, all jobs have a retry of 3 and this is set within your `config/queue.ts` under the `jobs` object.\n\nYou can also set the attempts on a call basis by passing the override as shown below:\n\n```ts\nqueue.dispatch(SomeJob, {...}, { attempts: 3 })\n```\n\n#### Delayed retries\n\nIf you need to add delays between retries, you can either set it globally via by adding this to your `config/queue.ts`:\n\n```ts\n// config/queue.ts\nimport { defineConfig } from '@rlanz/bull-queue'\n\nexport default defineConfig({\n  // ...\n\n  jobs: {\n    attempts: 3,\n    backoff: {\n      type: 'exponential',\n      delay: 5000,\n    }\n  }\n})\n```\n\nOr... you can also do it per job:\n\n```ts\nqueue.dispatch(Somejob, {...}, {\n  attempts: 3,\n  backoff: { type: 'exponential', delay: 5000 }\n})\n```\n\nWith that configuration above, BullMQ will first add a 5s delay before the first retry, 20s before the 2nd, and 40s for the 3rd.\n\nYou can visit [this page](https://docs.bullmq.io/guide/retrying-failing-jobs) on further explanation / other retry options.\n\n#### Running the queue\n\nRun the queue worker with the following ace command:\n\n```bash\nnode ace queue:listen\n\n# or\n\nnode ace queue:listen --queue=stripe\n\n# or\n\nnode ace queue:listen --queue=stripe,cloudflare\n```\n\nOnce done, you will see the message `Queue processing started`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRomainLanz%2Fadonis-bull-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRomainLanz%2Fadonis-bull-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRomainLanz%2Fadonis-bull-queue/lists"}