Configuration options for the job definition
Method decorator
import { JobsController, Define, Job } from 'agenda';
@JobsController()
class EmailJobs {
@Define({
name: 'sendWelcome',
concurrency: 5,
priority: 'high'
})
async sendWelcomeEmail(job: Job<{ userId: string; template: string }>) {
const { userId, template } = job.attrs.data;
await this.emailService.send(userId, template);
}
}
// Later, schedule the job:
await agenda.now('sendWelcome', { userId: '123', template: 'welcome' });
Method decorator that defines a job handler.
Jobs decorated with