From 6d56d03947adffed5540f29a77209d9194e9a52a Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 23 Jan 2019 17:00:20 -0800 Subject: [PATCH] declareQueue using wrong queue object - Issue When starting laravel worker using laravel-queue, this error is produced: ``` [2019-01-24 00:48:33] laravel.ERROR: Argument 1 passed to Enqueue\AmqpLib\AmqpContext::declareQueue() must implement interface Interop\Amqp\AmqpQueue, string given, called in /var/www/html/vendor/enqueue/laravel-queue/src/AmqpQueue.php on line 61 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Argument 1 passed to Enqueue\\AmqpLib\\AmqpContext::declareQueue() must implement interface Interop\\Amqp\\AmqpQueue, string given, called in /var/www/html/vendor/enqueue/laravel-queue/src/AmqpQueue.php on line 61 at /var/www/html/vendor/enqueue/amqp-lib/AmqpContext.php:163) [stacktrace] #0 /var/www/html/vendor/enqueue/laravel-queue/src/AmqpQueue.php(61): Enqueue\\AmqpLib\\AmqpContext->declareQueue('wat') #1 /var/www/html/vendor/enqueue/laravel-queue/src/AmqpQueue.php(47): Enqueue\\LaravelQueue\\AmqpQueue->declareQueue('wat') #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(247): Enqueue\\LaravelQueue\\AmqpQueue->pop('wat') ``` `AmqpContext->declareQueue` is expecting the `Interop\Amqp\AmqpQueue` retrieved on line 57; however, the queue name as a string is passed instead. - Fix Pass `$interopQueue` to `AmqpContext->declareQueue`. --- src/AmqpQueue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AmqpQueue.php b/src/AmqpQueue.php index d409849..49087be 100644 --- a/src/AmqpQueue.php +++ b/src/AmqpQueue.php @@ -57,6 +57,6 @@ protected function declareQueue($queue = null) $interopQueue = $this->getQueue($queue); $interopQueue->addFlag(\Interop\Amqp\AmqpQueue::FLAG_DURABLE); - $this->getQueueInteropContext()->declareQueue($queue); + $this->getQueueInteropContext()->declareQueue($interopQueue); } }