I have opened an issue for this: https://github.com/laravel/lumen-framework/issues/637
Extending Queue Worker and WorkCommand classes --> Unresolvable dependency in QueueManager
I have two very simple extensions of the Illuminate\Queue\Console\WorkCommand and Illuminate\Queue\Worker for use with webhooks.
My App\Webhooks\WebhookWorker simply overloads the handleJobException() method to implement exponential back-off for jobs that threw exceptions.
My App\Webhooks\WebhookWorkCommand simply overloads the WorkCommand __construct() method to accept a WebhookWorker and pass it to parent::__construct().
This is apparently enough to result in the Illuminate\Queue\QueueManager not knowing how to resolve $app in its constructor.
I have tried a number of bindings in my /bootstrap/app.php file to help resolve this, but nothing has worked.
This includes bindings for App\Webhooks\WebhookWorker, App\Webhooks\WebhookWorkCommand, and even Illuminate\Queue\QueueManager.
The only thing that gets me past the "unresolvable dependency" exception is not commenting out my command in App\Console\Kernel.
Does anyone know how to properly extend the Queue Worker and WorkCommand?
Apparently, I never tried simply defining it using ::class as the key for the singleton.
This worked:
$app->singleton(App\Webhooks\WebhookWorker::class, function ($app) {
return new App\Webhooks\WebhookWorker(
$app['queue'], $app['events'], $app[Illuminate\Contracts\Debug\ExceptionHandler::class]
);
});
Please or to participate in this conversation.