From 89e2d2466a6f7a62980611f01795fb6f113dd5bb Mon Sep 17 00:00:00 2001 From: Warnar Boekkooi Date: Wed, 17 Jun 2015 16:32:45 +0800 Subject: [PATCH] Cancel consuming a queue once done --- src/Command/QueueConsumeCommand.php | 6 ++++++ tests/Command/QueueConsumeCommandTest.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/Command/QueueConsumeCommand.php b/src/Command/QueueConsumeCommand.php index c40affc..c35ab5a 100644 --- a/src/Command/QueueConsumeCommand.php +++ b/src/Command/QueueConsumeCommand.php @@ -55,6 +55,12 @@ function (\AMQPEnvelope $envelope, \AMQPQueue $queue) use ($commandBus, &$limit) return $limit > 0; } ); + + # Cancel consumption of the queue + $consumeQueue->cancel(); + foreach ($queues as $queue) { + $queue->cancel(); + } } /** diff --git a/tests/Command/QueueConsumeCommandTest.php b/tests/Command/QueueConsumeCommandTest.php index e93871c..f00cb38 100644 --- a/tests/Command/QueueConsumeCommandTest.php +++ b/tests/Command/QueueConsumeCommandTest.php @@ -151,6 +151,8 @@ function (callable $callback) { } while (($callback($envelope, $queue))); } ); + $queue + ->shouldReceive('cancel'); return $queue; } }