ื“ืœื’ ืœืชื•ื›ืŸ ื”ืจืืฉื™

Background Job Architecture

Worker processes, job queues, and scheduled tasks.

Overviewโ€‹

Gauzy uses BullMQ (Redis-backed) for background job processing:

Job Typesโ€‹

QueueJobs
emailSend emails, notifications
integrationSync with third-party services
screenshotProcess screenshots
exportExport data to CSV/Excel
importImport data from files
cleanupArchive/delete old data

Creating a Jobโ€‹

@Injectable()
export class EmailService {
constructor(@InjectQueue("email") private emailQueue: Queue) {}

async sendWelcomeEmail(userId: string) {
await this.emailQueue.add(
"welcome",
{
userId,
template: "welcome",
},
{
attempts: 3,
backoff: { type: "exponential", delay: 5000 },
},
);
}
}

Processing a Jobโ€‹

@Processor("email")
export class EmailProcessor {
@Process("welcome")
async handleWelcome(job: Job) {
const { userId, template } = job.data;
await this.mailerService.send(userId, template);
}
}

Scheduled Tasksโ€‹

@Injectable()
export class CleanupService {
@Cron("0 0 * * *") // Daily at midnight
async cleanOldLogs() {
await this.activityLogService.deleteOlderThan(90);
}
}

Monitoringโ€‹

Use Bull Dashboard for queue monitoring:

GET /admin/queues