laravel-queue-rabbitmq
laravel-queue-rabbitmq copied to clipboard
[10.x] Error: Call to a member function make() on null
- Laravel/Lumen version: 6.20.18
- RabbitMQ version: 3.8.2
- Package version: 10.0.0
Describe the bug
The Illuminate\Queue\Jobs\Job (which is extended by VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob) expects a container in resolve($class) on line 215 in order to instantiate Illuminate\Queue\CallQueuedHandler class in Illuminate\Queue\Worker
I checked the Illuminate\Queue\Jobs\RedisJob which also extends Illuminate\Queue\Jobs\Job, and it has a container instance.
Steps To Reproduce
Save the 2 files from below, then run:
php artisan queue:work
and
php artisan dispatch:example
Example Job:
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class ExampleJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $message;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(string $message)
{
$this->message = $message;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
Log::info(sprintf('Worker says %s', $this->message));
sleep(10);
}
}
Dispatch Example Job:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Jobs\ExampleJob;
class DispatchExampleJob extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'dispatch:example';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
ExampleJob::dispatch('Hello World');
}
}
Current behavior
-
What happens with the worker? Keeps listening for new messages.
-
Is the message retried or put back into the queue? It is retried once.
-
Is the message acknowledged or rejected? Not sure. I can't see it in the failed queue.
-
Is the message unacked? It is retried once then the message is removed from the queue.
-
Is the message gone? No. It is successfully delivered, and retried once.
Expected behavior
I expect it to execute my queued job.
Additional context
Add any other context about the problem or describe the use-case.


@vyuldashev Is this a common error?
composer require vladimir-yuldashev/laravel-queue-rabbitmq:~10.0 There's no this issue when I upgrade to v10.2.3 ~
- Laravel/Lumen version: 6.20.18
- RabbitMQ version: 3.8.2
- Package version: 10.0.0
Describe the bug
The
Illuminate\Queue\Jobs\Job(which is extended byVladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob) expects a container inresolve($class)on line215in order to instantiateIlluminate\Queue\CallQueuedHandlerclass inIlluminate\Queue\WorkerI checked the
Illuminate\Queue\Jobs\RedisJobwhich also extendsIlluminate\Queue\Jobs\Job, and it has a container instance.Steps To Reproduce
Save the 2 files from below, then run:
php artisan queue:workandphp artisan dispatch:exampleExample Job:
<?php namespace App\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Log; class ExampleJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; protected $message; /** * Create a new job instance. * * @return void */ public function __construct(string $message) { $this->message = $message; } /** * Execute the job. * * @return void */ public function handle() { Log::info(sprintf('Worker says %s', $this->message)); sleep(10); } }Dispatch Example Job:
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use App\Jobs\ExampleJob; class DispatchExampleJob extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'dispatch:example'; /** * The console command description. * * @var string */ protected $description = 'Command description'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return mixed */ public function handle() { ExampleJob::dispatch('Hello World'); } }Current behavior
- What happens with the worker? Keeps listening for new messages.
- Is the message retried or put back into the queue? It is retried once.
- Is the message acknowledged or rejected? Not sure. I can't see it in the failed queue.
- Is the message unacked? It is retried once then the message is removed from the queue.
- Is the message gone? No. It is successfully delivered, and retried once.
Expected behavior
I expect it to execute my queued job.
Additional context
Add any other context about the problem or describe the use-case.
composer require vladimir-yuldashev/laravel-queue-rabbitmq:~10.0 There's no this issue when I upgrade to v10.2.3 ~
Version 10 of this package is no longer supported. If you are still experiencing this issue with a recent version of the package, please open a separate issue.