Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch missing queue exeception on queueExists #63

Merged
merged 2 commits into from
Dec 18, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 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 @@ -311,13 +312,15 @@ public function queueExists()
return true;
}

$result = $this->sqs->getQueueUrl([
'QueueName' => $this->getNameWithPrefix()
]);
try {
$result = $this->sqs->getQueueUrl([
'QueueName' => $this->getNameWithPrefix()
]);

if($this->queueUrl = $result->get('QueueUrl')) {
return true;
}
if ($this->queueUrl = $result->get('QueueUrl')) {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind setting the queueUrl back into cache here? Its an attempt to keep us from having to hit the API to keep track of it, any time we do, let's reset the cache.

}
} catch (SqsException $e) {}

return false;
}
Expand Down Expand Up @@ -409,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