Open lordlele opened 7 years ago
Maybe the way to allow developers to process code out of the internally provided by their contracts (interfaces) and API, is to be able to access its internal driver (i.e. https://github.com/yiisoft/yii2-queue/blob/master/src/drivers/beanstalk/Queue.php#L138) so, if a project fails x amount of times, developer is able to actually do whatever he wishes (bury, remove, etc...) not just with beanstalkd but with the rest of the storage systems provided.
I did something like that on one of my libraries: https://github.com/2amigos/mailer-library/blob/master/src/Queue/Backend/QueueStoreAdapterInterface.php#L14
I didn't say that behavior must be forced, but only configurable. If I want to delete failed jobs and then search errors in logs, I can do that. But, if I want to bury jobs to later inspection, fix and re-enqueue, I want to be able to do that.
I think you can already do this:
handleMessage()
returns true
.handleMessage()
returns the result of handleError
Specifically the last 2 points are interesting.
Since the job was buried it will not be re queued, but it can still be deleted in case the job succeeds.
@tonydspaniard As far as I can tell, you already have access to the queue driver. This is because the magic getter in Yii exposes protected getters...
if ($queue instanceof yii\queue\beanstalk\Queue) {
/** @var Pheanstalk\Pheanstalk $pheanstalk */
$pheanstalk = $queue->pheanstalk;
}
This is of course not a very nice solution since it depends on non-public APIs..
Hi, I'm asking once more for this. As you can see #62 was closed without a real answer, because buring jobs is part of Beanstalkd core and it's a common practice that all Beanstalkd client implements (like Pheanstalk). I've clearly stated why bury jobs can be useful and that behavior can be configurable (delete failed jobs or otherwise bury failed jobs).
Did you maybe accept a PR for this?