From c47655903b50d844494fefd9db66aebbe42cdc28 Mon Sep 17 00:00:00 2001 From: Hilari Moragrega Date: Fri, 20 Oct 2017 13:05:43 +0200 Subject: [PATCH 1/2] fix purging queue and allow gracefull stops --- .../Infrastructure/AWS/v20121105/Queue/QueueReader.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Cmp/Queues/Infrastructure/AWS/v20121105/Queue/QueueReader.php b/src/Cmp/Queues/Infrastructure/AWS/v20121105/Queue/QueueReader.php index 1ff6883..f6528d1 100644 --- a/src/Cmp/Queues/Infrastructure/AWS/v20121105/Queue/QueueReader.php +++ b/src/Cmp/Queues/Infrastructure/AWS/v20121105/Queue/QueueReader.php @@ -3,6 +3,7 @@ namespace Cmp\Queues\Infrastructure\AWS\v20121105\Queue; use Aws\Sqs\SqsClient; +use Cmp\Queues\Domain\Queue\Exception\GracefulStopException; use Cmp\Queues\Domain\Queue\Exception\ReaderException; use Cmp\Queues\Domain\Queue\Exception\TimeoutReaderException; use Cmp\Queues\Domain\Queue\QueueReader as DomainQueueReader; @@ -69,6 +70,8 @@ public function read(callable $callback, $timeout=0) try { $this->consume($timeout); + } catch(GracefulStopException $e) { + $this->logger->info("Gracefully stopping the AWS queue reader", $e->getCode(), $e); } catch(TimeoutReaderException $e) { throw $e; } catch(\Exception $e) { @@ -81,7 +84,9 @@ public function read(callable $callback, $timeout=0) */ public function purge() { - $this->sqs->purgeQueue($this->queueUrl); + $this->sqs->purgeQueue([ + 'QueueUrl' => $this->queueUrl, + ]); } /** From 50545b429c7e2b9abef9658aaa6fd5563e59f499 Mon Sep 17 00:00:00 2001 From: Hilari Moragrega Date: Fri, 20 Oct 2017 13:09:05 +0200 Subject: [PATCH 2/2] Fix log message --- .../Queues/Infrastructure/AWS/v20121105/Queue/QueueReader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cmp/Queues/Infrastructure/AWS/v20121105/Queue/QueueReader.php b/src/Cmp/Queues/Infrastructure/AWS/v20121105/Queue/QueueReader.php index f6528d1..748529a 100644 --- a/src/Cmp/Queues/Infrastructure/AWS/v20121105/Queue/QueueReader.php +++ b/src/Cmp/Queues/Infrastructure/AWS/v20121105/Queue/QueueReader.php @@ -71,7 +71,7 @@ public function read(callable $callback, $timeout=0) try { $this->consume($timeout); } catch(GracefulStopException $e) { - $this->logger->info("Gracefully stopping the AWS queue reader", $e->getCode(), $e); + $this->logger->info("Gracefully stopping the AWS queue reader", ["exception" => $e]); } catch(TimeoutReaderException $e) { throw $e; } catch(\Exception $e) {