Queue with a job that need to search for a near by drivers in some attempts, if user wants to cancel this search i need to remove job from queue.
When i tried to job.remove() i got a error because job is lock as said here: https://github.com/OptimalBits/bull/issues/575
So checking the documentation i found job.discard(): https://github.com/OptimalBits/bull/blob/master/REFERENCE.md#jobdiscard
where "job is never ran again even if attemptsMade is less than job.attempts"
but if use this method the job keep trying to execute inside queue.
How can i remove job execution from queue even if attemptsMade is less than job.attempts ?
const DEFAULT_QUEUE_OPTIONS: Queue.JobOptions = {
attempts: 90,
backoff: {
type: "fixed",
delay: 3000
},
removeOnComplete: true,
removeOnFail
}
export const cancelPendingTripRequestJob = (tripRequest: TripRequest): void => {
const { id } = tripRequest;
pendingTripRequestsQueue.getJob(id).then((job: any) => {
if (!job) { return; }
console.log("discarding job");
job.discard();
});
};
"bull": "^3.3.7"
application log:
_2018-01-05T10:30:07.061589+00:00 app[web.1]: [pendingTripRequestsQueue] Failed Job: No drivers available
2018-01-05T10:30:10.073846+00:00 app[web.1]: [pendingTripRequestsQueue] Failed Job: No drivers available
2018-01-05T10:30:12.202610+00:00 app[web.1]: Trip cancelled 645168d0-f203-11e7-b733-addfcf0a2fab
2018-01-05T10:30:12.206370+00:00 app[web.1]: discarding job
2018-01-05T10:30:13.076323+00:00 app[web.1]: Processing job pendingTripRequestsQueue Fri Jan 05 2018 10:30:13 GMT+0000 (UTC) (Trip request 645168d0-f203-11e7-b733-addfcf0a2fab)
2018-01-05T10:30:13.130976+00:00 app[web.1]: [pendingTripRequestsQueue] Failed Job: No drivers available
2018-01-05T10:30:16.095617+00:00 app[web.1]: Processing job pendingTripRequestsQueue Fri Jan 05 2018 10:30:16 GMT+0000 (UTC) (Trip request 645168d0-f203-11e7-b733-addfcf0a2fab)
2018-01-05T10:30:16.105862+00:00 app[web.1]: [pendingTripRequestsQueue] Failed Job: No drivers available
2018-01-05T10:30:19.103893+00:00 app[web.1]: Processing job pendingTripRequestsQueue Fri Jan 05 2018 10:30:19 GMT+0000 (UTC) (Trip request 645168d0-f203-11e7-b733-addfcf0a2fab)
2018-01-05T10:30:19.109510+00:00 app[web.1]: [pendingTripRequestsQueue] Failed Job: No drivers available_
@manast is there a reason discard isn鈥檛 persisted to redid?
@TomKaltz I don't know, actually. It is a loosy implementation, would not work in a concurrent scenario or anything. I will see if I can implement a proper discard and also a cancel functionality in the following days. I am in a busy period right now with limited time for bull...
Any news with this feature?
Hello, are there any updates on this issue ?
Most helpful comment
Hello, are there any updates on this issue ?