yii2-queue icon indicating copy to clipboard operation
yii2-queue copied to clipboard

Ability to take off reserve from job

Open acidka opened this issue 6 years ago • 4 comments

Can we add functionality to take off reserve from job to make it immediately available for workers? After job being reserved we need to wait TTR before job expired and moved back to waiting list to start new attempt. Also i found in documentation dirty workaround for this problem:

Yii::$app->queue->on(Queue::EVENT_AFTER_ERROR, function ($event) {
    if ($event->error instanceof TemporaryUnprocessableJobException) {
        $queue = $event->sender;
        $queue->delay(7200)->push($event->job);
    }
});

It works great but we are pushing New job with new ID attached to it so old one is lost and it makes mess in logs etc

Maybe we can add some release() method to handle it:

Yii::$app->queue->on(Queue::EVENT_AFTER_ERROR, function ($event) {
    if ($event->error instanceof TemporaryUnprocessableJobException) {
        $queue = $event->sender;
        $queue->delay(7200)->release($event->job);
    }
});

For an example in DB driver it's simply must reset reserved_at to null and update pushed_at to current time()

acidka avatar Apr 09 '18 14:04 acidka

Beanstalk supports the release($id, $priority, $delay) command for releasing a job back to the queue without changing its id.

(Just a note to illustrate that for some drivers this implementation would be really trivial)

SamMousa avatar Jul 10 '18 08:07 SamMousa

@SamMousa thanks but i already implemented this with other needed features "dynamic channel", "parent queue", "queue title" etc...

acidka avatar Jul 10 '18 09:07 acidka

In that case this can / should be closed? :)

SamMousa avatar Jul 10 '18 09:07 SamMousa

@SamMousa i think it's must be implemented anyway...

acidka avatar Jul 10 '18 09:07 acidka