// app.module.ts import { BullModule } from '@nestjs/bull'; @Module({ imports: [ BullModule.forRoot({ redis: { host: process.env.REDIS_HOST, port: parseInt(process.env.REDIS_PORT), password: process.env.REDIS_PASSWORD, }, // ── Applied to ALL queues globally ────────────────────────────── defaultJobOptions: { removeOnComplete: { age: 3600, // remove completed jobs older than 1 hour (seconds) count: 100, // but always keep the last 100 regardless of age }, removeOnFail: { age: 86400, // keep failed jobs for 24 hours for debugging count: 200, }, attempts: 3, backoff: { type: 'exponential', delay: 5000, }, }, }), // Individual queues — no need to repeat defaultJobOptions BullModule.registerQueue({ name: 'helpers' }), BullModule.registerQueue({ name: 'notification' }), BullModule.registerQueue({ name: 'log' }), BullModule.registerQueue({ name: 'optimize-image' }), ], }) export class AppModule {} // If you use forRootAsync (with ConfigService) BullModule.forRootAsync({ imports: [ConfigModule], inject: [ConfigService], useFactory: (config: ConfigService) => ({ connection: { host: config.get('REDIS_HOST'), port: config.get('REDIS_PORT'), password: config.get('REDIS_PASSWORD'), db: config.get('REDIS_DB', 0), }, defaultJobOptions: { removeOnComplete: { age: 3600, count: 100 }, removeOnFail: { age: 86400, count: 200 }, attempts: 3, backoff: { type: 'exponential', delay: 5000 }, }, }), }),