-
Notifications
You must be signed in to change notification settings - Fork 222
Open
Labels
Description
Is it possible to set some kind of lifespan for a job? If a job never was processed by a worker it should be removed from the queue after x seconds.
I am looking for something like the TTL of RabbitMQ.
Currently I have a function that checks every second if the timestamp of jobs that are waiting are older than x seconds and if the status of each job is "created" - if so the job will get removed from the queue. Is there any other way to do this currently?
setInterval(() => {
queue.getJobs('waiting', {start: 0, end: 100}).then((jobs) => {
jobs.forEach((job) => {
if (job.status === "created") {
const jobDurationInSeconds = moment.duration(moment().diff(moment(job.options.timestamp))).seconds();
if (jobDurationInSeconds > 1.5) {
console.log(`Killing Job: ${job.id}`);
job.remove();
}
}
});
});
}, 1000);
Reactions are currently unavailable