本文整理汇总了PHP中Aws\Sqs\SqsClient::getQueueUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP SqsClient::getQueueUrl方法的具体用法?PHP SqsClient::getQueueUrl怎么用?PHP SqsClient::getQueueUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\Sqs\SqsClient
的用法示例。
在下文中一共展示了SqsClient::getQueueUrl方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readQueueAttributes
/**
* @param string $name
* @throws OperationException
* @return array
*/
protected function readQueueAttributes($name)
{
try {
// grab url before in order to read attributes
$queueUrl = $this->client->getQueueUrl(['QueueName' => $name]);
$attributes = $this->client->getQueueAttributes(['QueueUrl' => $queueUrl->get('QueueUrl'), 'AttributeNames' => ['All']]);
return $attributes->get('Attributes');
} catch (\Exception $e) {
throw new OperationException(sprintf('Cannot read attributes for queue "%s":%s', $name, $e->getMessage()), $e->getCode(), $e);
}
}
示例2: __construct
/**
* AwsSqsQueueAdapter constructor.
*
* @param string $queueName The name of the SQS queue
* @param SqsClient $sqsClient An SQS client
* @param array $config Array of config values
*/
public function __construct($queueName, SqsClient $sqsClient, $config = array())
{
$this->queueName = $queueName;
$this->sqsClient = $sqsClient;
$this->sqsUrl = $this->sqsClient->getQueueUrl(array('QueueName' => $this->queueName))->get('QueueUrl');
$this->config = $config;
}
示例3: __construct
/**
* Constructor
*
* @param SqsClient $sqsClient
* @param SqsQueueOptions $options
* @param string $name
* @param JobPluginManager $jobPluginManager
*/
public function __construct(SqsClient $sqsClient, SqsQueueOptions $options, $name, JobPluginManager $jobPluginManager)
{
$this->sqsClient = $sqsClient;
$this->queueOptions = $options;
parent::__construct($name, $jobPluginManager);
// If an URL has explicitly been given in the options, let's use it, otherwise we dynamically fetch it
if (!$this->queueOptions->getQueueUrl()) {
$queue = $this->sqsClient->getQueueUrl(array('QueueName' => $name));
$this->queueOptions->setQueueUrl($queue['QueueUrl']);
}
}
示例4: getQueueUrl
/**
* @param string $queueId
* @return string
*/
protected function getQueueUrl($queueId)
{
if (empty($this->queueUrl)) {
if (empty($queueId)) {
$queueId = $this->getQueueId();
}
$response = $this->queueClient->getQueueUrl(["QueueName" => $queueId]);
$this->queueUrl = $response->get("QueueUrl");
}
return $this->queueUrl;
}
示例5: __construct
/**
* Constructs the wrapper using the name of the queue and the aws credentials
*
* @param $name
* @param $aws_credentials
*/
public function __construct($name, $aws_credentials)
{
try {
// Setup the connection to the queue
$this->name = $name;
$this->aws_credentials = $aws_credentials;
$this->sqs_client = new SqsClient($this->aws_credentials);
// Get the queue URL
$this->url = $this->sqs_client->getQueueUrl(array('QueueName' => $this->name))->get('QueueUrl');
} catch (Exception $e) {
echo 'Error getting the queue url ' . $e->getMessage();
}
}
示例6: execute
/**
* Executes the current command
*
* @param InputInterface $input
* @param OutputInterface $output
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$queueName = $input->getOption('queue');
try {
$queueUrl = $this->sqsClient->getQueueUrl(['QueueName' => $queueName])['QueueUrl'];
} catch (SqsException $exception) {
$output->writeln(sprintf('<error>Impossible to retrieve URL for queue "%s". Reason: %s</error>', $queueName, $exception->getMessage()));
return;
}
$uri = rtrim($input->getOption('server'), '/') . '/' . ltrim($input->getOption('path'), '/');
while (true) {
$messages = $this->sqsClient->receiveMessage(['QueueUrl' => $queueUrl, 'AttributeNames' => ['All'], 'MaxNumberOfMessages' => 1, 'WaitTimeSeconds' => 20]);
if (!$messages->hasKey('Messages')) {
continue;
}
$this->processMessage($messages['Messages'][0], $uri, $queueName, $queueUrl, $output);
}
}
示例7: getQueueUrl
public function getQueueUrl()
{
if (!$this->url) {
$result = $this->client->getQueueUrl(["QueueName" => $this->name]);
if ($result['QueueUrl']) {
$this->url = $result['QueueUrl'];
} else {
throw new \RuntimeException("Cannot find queue url for queue named {$this->name}");
}
}
return $this->url;
}
示例8: queueExists
/**
* Return the Queue Url
*
* This method relies on in-memory cache and the Cache provider
* to reduce the need to needlessly call the create method on an existing
* Queue.
*
* @return boolean
*/
public function queueExists()
{
if (isset($this->queueUrl)) {
return true;
}
$key = $this->getNameWithPrefix() . '_url';
if ($this->cache->contains($key)) {
$this->queueUrl = $this->cache->fetch($key);
return true;
}
$result = $this->sqs->getQueueUrl(['QueueName' => $this->getNameWithPrefix()]);
if ($this->queueUrl = $result->get('QueueUrl')) {
return true;
}
return false;
}
示例9: purgeQueue
/**
* @inheritdoc
*
* @throws SqsException
*/
public function purgeQueue($queueName, $priority = null)
{
if (null === $priority) {
$priorities = $this->priorityHandler->getAll();
foreach ($priorities as $priority) {
$this->purgeQueue($queueName, $priority);
}
return $this;
}
if (empty($queueName)) {
throw new InvalidArgumentException('Parameter queueName empty or not defined.');
}
$queueUrl = $this->sqsClient->getQueueUrl(['QueueName' => $this->getQueueNameWithPrioritySuffix($queueName, $priority)])->get('QueueUrl');
$this->sqsClient->purgeQueue(['QueueUrl' => $queueUrl]);
return $this;
}
示例10: purgeQueue
/**
* @inheritdoc
*
* @throws \InvalidArgumentException
* @throws QueueAccessException
*/
public function purgeQueue($queueName, Priority $priority = null)
{
if (null === $priority) {
$priorities = $this->priorityHandler->getAll();
foreach ($priorities as $priority) {
$this->purgeQueue($queueName, $priority);
}
return $this;
}
if (empty($queueName)) {
throw new \InvalidArgumentException('Queue name empty or not defined.');
}
try {
$queueUrl = $this->sqsClient->getQueueUrl(['QueueName' => $this->getQueueNameWithPrioritySuffix($queueName, $priority)])->get('QueueUrl');
$this->sqsClient->purgeQueue(['QueueUrl' => $queueUrl]);
} catch (SqsException $e) {
throw new QueueAccessException('Cannot purge queue', 0, $e);
}
return $this;
}
示例11: testErrorParsing
/**
* @expectedException \Aws\Sqs\Exception\SqsException
*/
public function testErrorParsing()
{
$this->sqs->getQueueUrl(array('QueueName' => 'php-fake-queue'));
}
示例12: getQueueUrl
/**
* Returns queue url
* @param string $queueName The name of the queue
* @return string The queue url
*/
public function getQueueUrl($queueName)
{
if (array_key_exists($queueName, $this->queueUrls)) {
return $this->queueUrls[$queueName];
}
$result = $this->client->getQueueUrl(array('QueueName' => $queueName));
if ($result && ($queueUrl = $result['QueueUrl'])) {
return $this->queueUrls[$queueName] = $queueUrl;
}
throw new \InvalidArgumentException("Queue url for queue {$queueName} not found");
}