laravel6 使用rabbitmq报错:Call to a member function make() on null at Queue\\Jobs\\Job.php:215

报错信息

[previous exception] [object] (Error(code: 0): Call to a member function make() on null at ~\\vendor\\laravel\\framework\\src\\Illuminate\\Queue\\Jobs\\Job.php:215)

另外,以下情况报错可能也是由于此问题产生,可以参考是否能够解决:

 PhpAmqpLib\Exception\AMQPProtocolChannelException  : PRECONDITION_FAILED - inequivalent arg 'x-dead-letter-exchange' for queue 'lauwen' in vhost 'lauwen': received the value 'lauwen' of type 'longstr' but current is none

PhpAmqpLib\Exception\AMQPProtocolChannelException  : PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'lauwen' in vhost 'lauwen': received 'true' but current is 'false'

原因及解决

以上原因是由于使用的库vladimir-yuldashev/laravel-queue-rabbitmq版本问题造成的,根据该库文档laravel6需要依赖v9.0或v10.0,所以我在安装过程中限制了版本为10.0,如下:

composer require vladimir-yuldashev/laravel-queue-rabbitmq:10.0

这样就会造成以上问题的出现,导致队列消费程序不能正常消费,正确安装是不指定具体的版本:

composer require vladimir-yuldashev/laravel-queue-rabbitmq:~10.0

这样安装的将是v10.2.3版本的库,报错就不会发生。

猜你喜欢

转载自blog.csdn.net/Douz_lungfish/article/details/123936585