Skip to content

Commit

Permalink
Merge pull request #18 from CMProductions/fix_aws_reader
Browse files Browse the repository at this point in the history
fix purging queue and allow graceful stops
  • Loading branch information
Hilari Moragrega authored Oct 20, 2017
2 parents c0e7a7b + 50545b4 commit f016e70
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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,
]);
}

/**
Expand Down

0 comments on commit f016e70

Please sign in to comment.