@nest-batch/bullmq
v0.2.5
Published
BullMQ runtime adapter for @nest-batch/core — runs batch jobs and partitioned steps as BullMQ queues and workers.
Downloads
2,567
Readme
@nest-batch/bullmq
BullMQ transport adapter for @nest-batch/core.
Korean: README.ko.md
Install
pnpm add @nest-batch/core @nest-batch/bullmq bullmq ioredisPublic Imports
import { BullmqAdapter, BullMqExecutionStrategy, BULLMQ_MODULE_OPTIONS } from '@nest-batch/bullmq';Wiring
Use BullMQ when the launcher should enqueue work and a worker should consume it through Redis.
import { BullmqAdapter } from '@nest-batch/bullmq';
import { NestBatchModule } from '@nest-batch/core';
NestBatchModule.forRoot({
adapters: {
persistence: persistenceAdapter,
transport: BullmqAdapter.forRoot({
connection: {
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT ?? 6379),
keyPrefix: 'my-app:',
},
autoStartWorker: process.env.BATCH_WORKER === '1',
}),
},
});Run the same application image in launcher and worker roles:
BATCH_WORKER=0 node dist/main.js
BATCH_WORKER=1 node dist/main.jsScheduling
When autoStartWorker is enabled, this package can also bridge discovered
@BatchScheduled entries into job launches.
Scheduler definitions are shared Redis/Valkey state. Each application instance upserts the desired schedules on startup, but shutdown closes only that instance's worker and connections. Removing or renaming a schedule therefore requires explicit cleanup or a separate desired-state reconciliation process.
When upgrading from 0.2.3, an old task can still remove scheduler definitions
during shutdown. Use a one-time stop-before-start rollout (0 -> 1) or explicitly
re-register schedules after the rollout. Normal rolling deployments are safe
once every running task uses the fixed version.
