laravel-queue-rabbitmq icon indicating copy to clipboard operation
laravel-queue-rabbitmq copied to clipboard

local.ERROR: Trying to access array offset on value of type null

Open farshidrezaei opened this issue 3 years ago • 5 comments

  • Laravel/Lumen version: 8.57

I run rabbit:consume rabbit --queue=test , get this error in my logs:

[2021-08-30 11:53:22] local.ERROR: Trying to access array offset on value of type null {"exception":"[object] (ErrorException(code: 0): Trying to access array offset on value of type null at */vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:315)

farshidrezaei avatar Aug 30 '21 07:08 farshidrezaei

same error

ijunaidali avatar Nov 03 '21 16:11 ijunaidali

It's because your payload is an invalid Laravel payload schema and Laravel cannot parse it and it throws an error. If you use a custom payload not coming from another Laravel app, you have to extend the built-in class and create the payload yourself using this link: https://github.com/vyuldashev/laravel-queue-rabbitmq/blob/master/README.md#use-your-own-rabbitmqjob-class

sky93 avatar Dec 31 '21 10:12 sky93

Please, I have this error too. But in my case, I already created a custom job class and extended rabbitmq job and added it to the queue config. 'job' => \App\Jobs\RabbitMQJob::class,

But I still face the same error. Any suggestion?

angwa avatar Apr 28 '22 10:04 angwa

Just in case there is someone still getting this error, in my case the getName function was the problem! Do like @angwa did and override getName function in \App\Jobs\RabbitMQJob::class: 'job' => \App\Jobs\RabbitMQJob::class,

use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob as BaseJob;

RabbitMQJob extends BaseJob {
  // override
  public function getName()
  {
       return "";
  }
}

then run php artisan queue:work

gesitaric avatar Aug 26 '22 05:08 gesitaric

Thank you for your response @geskeitaloricardo . After a lot of struggles. I noticed that Laravel has a specific format for receiving jobs. I was sending the job from a python script to Laravel as a plain text without formatting it to Laravel job. Thus, I was getting that error. I changed the message I was sending from python to contain job id and other stuff and got it working

angwa avatar Aug 26 '22 19:08 angwa

Closing as seeming to be resolved.

M-Porter avatar Jan 31 '23 19:01 M-Porter