Skip to content

Commit

Permalink
Add AWS check for topic existence
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Dufel committed Feb 10, 2015
1 parent 0fad2ed commit deb9137
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Provider/AwsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace Uecode\Bundle\QPushBundle\Provider;

use Aws\Common\Aws;
use Aws\Sns\Exception\NotFoundException;
use Aws\Sqs\SqsClient;
use Aws\Sqs\Exception\SqsException;
use Doctrine\Common\Cache\Cache;
Expand Down Expand Up @@ -411,6 +412,21 @@ public function topicExists()
return true;
}

if (!empty($this->queueUrl)) {
$queueArn = $this->sqs->getQueueArn($this->queueUrl);
$topicArn = str_replace('sqs', 'sns', $queueArn);
try {
$result = $this->sns->getTopicAttributes([
'TopicArn' => $topicArn
]);
} catch (NotFoundException $e) {
return false;
}
$this->topicArn = $topicArn;
$this->cache->save($key, $this->topicArn);
return true;
}

return false;
}

Expand Down

0 comments on commit deb9137

Please sign in to comment.