Skip to content
Skillv1.0.0

nestjs-bullmq

Implement BullMQ job workflows in NestJS. Use when building queue processors, redis-throttler, Upstash limits, idle polling, stalled jobs, and retention policies.

by FilippoDeSilva(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from FilippoDeSilva/skills (skills/nestjs/nestjs-bullmq/SKILL.md). Install upstream with npx skills add FilippoDeSilva/skills --skill nestjs-bullmq. Copyright stays with the author (MIT).

NestJS BullMQ Implementation

Priority: P0 (Critical)

Guidelines

  • Set idle polling: Add drainDelay + stalledInterval + maxStalledCount to every @Processor. Default drainDelay (5 ms) burns 570M Redis commands/day at idle. See patterns.md.
  • Throttle worker error logs: BullMQ workers emit raw unhandled ReplyErrors on Redis failure (e.g. Upstash rate limits). Always extend BaseProcessor instead of WorkerHost to rate-limit these logs. See patterns.md.
  • Set job retention: Add removeOnComplete, removeOnFail, attempts, backoff to every BullModule.registerQueue. See patterns.md.
  • Use shared constants: All numeric options live in src/common/constants/bull-queue.constants.ts. Key constants: QUEUE_DRAIN_DELAY_MS (10 000 ms), QUEUE_STALLED_INTERVAL_MS (60 000 ms). Use getSharedBullQueueOptions helper for registerQueue. Queue/job names go in {feature}.constants.ts. Never inline magic numbers.
  • Wrap every queue.add(): Persist DB record first, then enqueue inside try-catch. Redis errors must not surface as 500s. See patterns.md.
  • Throttler fail-open: ThrottlerGuard registered as global APP_GUARD — Redis blip propagates errors to ALL HTTP routes. RedisThrottlerStorage.increment() must catch all Redis errors and return fail-open pass-through record. Redis blip must not kill all HTTP routes. See patterns.md.
  • Guard new queues: Follow isRedisEnabled() conditional + mock token pattern in every module. NestJS DI throws on startup without mock.
  • Keep processor and cron: Cron schedules; processor executes. Both always required — they complementary. See patterns.md.
  • Use local Redis in dev: Never point dev machines at Upstash — idle workers exhaust free tier (500K/day) in minutes.

Anti-Patterns

  • No bare @Processor(NAME): Always pass worker options object with drainDelay and stalledInterval.
  • No bare WorkerHost extension: Always extend BaseProcessor instead to intercept and rate-limit worker errors.
  • No registerQueue without defaultJobOptions: Omitting causes unbounded Redis memory growth.
  • No inline numbers: Use bull-queue.constants.ts — never write 10_000, 60_000, 50, 20, 3, or 5_000 directly.
  • No unguarded queue.add(): Wrap in try-catch; persist DB state first.
  • No throws in throttler increment: Catch Redis errors; return fail-open record.
  • No missing mock token: Provide getQueueToken mock when redisEnabled = false.
  • No removing processor because cron exists: They serve different roles.
  • No cloud Redis in dev: Use local Docker Redis.

References

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/filippodesilva-skills-nestjs-bullmq/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

filippodesilva-skills-nestjs-bullmq.ocm.jsonjson
{
  "ocm": "1",
  "id": "filippodesilva-skills-nestjs-bullmq",
  "kind": "skill",
  "name": "nestjs-bullmq",
  "description": "Implement BullMQ job workflows in NestJS. Use when building queue processors, redis-throttler, Upstash limits, idle polling, stalled jobs, and retention policies.",
  "publisher": "FilippoDeSilva",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "nestjs",
      "bullmq",
      "queue",
      "background-job",
      "worker",
      "processor",
      "github"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Implement BullMQ job workflows in NestJS. Use when building queue processors, redis-throttler, Upstash limits, idle polling, stalled jobs, and retention policies."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "github",
      "repository": "https://github.com/FilippoDeSilva/skills",
      "path": "skills/nestjs/nestjs-bullmq/SKILL.md",
      "ref": "a1d985c24c49d918b5d76bb6e5a66903ef830cd3",
      "url": "https://github.com/FilippoDeSilva/skills/blob/a1d985c24c49d918b5d76bb6e5a66903ef830cd3/skills/nestjs/nestjs-bullmq/SKILL.md",
      "key": "FilippoDeSilva/skills/skills/nestjs/nestjs-bullmq/SKILL.md"
    },
    "license": "MIT"
  },
  "instructions": "# NestJS BullMQ Implementation\n\n## **Priority: P0 (Critical)**\n\n## Guidelines\n\n- **Set idle polling**: Add `drainDelay` + `stalledInterval` + `maxStalledCount` to every `@Processor`. Default `drainDelay` (5 ms) burns 570M Redis commands/day at idle. See [patterns.md](references/patterns.md#3-processor-consumer-with-correct-worker-options).\n- **Throttle worker error logs**: BullMQ workers emit raw unhandled ReplyErrors on Redis failure (e.g. Upstash rate limits). Always extend `BaseProcessor` instead of `WorkerHost` to rate-limit these logs. See [patterns.md](references/patterns.md#4-base-proce",
  "cost": {
    "context_tokens": 784
  }
}

Fetch it by URL: GET /api/v1/registry/filippodesilva-skills-nestjs-bullmq/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.