diff --git a/src/Cmp/Queues/Infrastructure/AWS/v20121105/Queue/QueueReader.php b/src/Cmp/Queues/Infrastructure/AWS/v20121105/Queue/QueueReader.php index 1ff6883..748529a 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", ["exception" => $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, + ]); } /**