Optionalbackoffimport { backoffStrategies } from 'agenda';
// Using built-in exponential backoff
agenda.define('myJob', handler, {
backoff: backoffStrategies.exponential({ delay: 1000, maxRetries: 5 })
});
// Using a preset
agenda.define('myJob', handler, {
backoff: backoffStrategies.standard()
});
// Custom strategy
agenda.define('myJob', handler, {
backoff: (ctx) => ctx.attempt <= 3 ? 1000 * ctx.attempt : null
});
Optionalconcurrencyhow many jobs of this kind can run in parallel/simultanously per Agenda instance
lock lifetime in milliseconds
max number of locked jobs of this kind
OptionalloggingEnable or disable persistent logging for this job definition.
When false, no log entries are written for jobs of this type,
even if a global job logger is configured.
Defaults to true (logging enabled when a job logger is configured).
OptionalpriorityHigher priority jobs will run first.
OptionalremoveAutomatically remove this job from database after successful completion (one-time jobs only)
Backoff strategy for automatic retries on failure. Can be a built-in strategy from
backoffStrategiesor a custom function.