From 4599ac87c2c4160b54a55876f67d47fc85eed4f6 Mon Sep 17 00:00:00 2001 From: Abed Halawi Date: Wed, 7 Nov 2018 17:47:42 +0200 Subject: [PATCH] move handler initialisation to inside the message receipt callback --- src/Consumer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Consumer.php b/src/Consumer.php index 2d90a6d..2efbc11 100644 --- a/src/Consumer.php +++ b/src/Consumer.php @@ -139,10 +139,10 @@ public function listenToQueue($handlerClass, BowlerExceptionHandler $exceptionHa $channel->queue_bind($this->queueName, $this->exchangeName); } - // Instantiate Handler - $queueHandler = app($handlerClass); + $callback = function ($message) use ($handlerClass, $exceptionHandler) { + // Instantiate Handler + $queueHandler = app($handlerClass); - $callback = function ($message) use ($queueHandler, $exceptionHandler) { $broker = new MessageBroker($message); try {