当前位置: 首页>>代码示例>>PHP>>正文


PHP SqsClient::getQueueAttributes方法代码示例

本文整理汇总了PHP中Aws\Sqs\SqsClient::getQueueAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP SqsClient::getQueueAttributes方法的具体用法?PHP SqsClient::getQueueAttributes怎么用?PHP SqsClient::getQueueAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Aws\Sqs\SqsClient的用法示例。


在下文中一共展示了SqsClient::getQueueAttributes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
     }
 }
开发者ID:ronan-gloo,项目名称:qu,代码行数:16,代码来源:SqsQueueManager.php

示例2: is_message

 /**
  *
  * @return number
  */
 public function is_message($queue = '')
 {
     $result = $this->sqs->getQueueAttributes(['QueueUrl' => $queue, 'AttributeNames' => ['ApproximateNumberOfMessages', 'ApproximateNumberOfMessagesNotVisible', 'ApproximateNumberOfMessagesDelayed']]);
     $queuecount = 0;
     foreach ($result->get("Attributes") as $key => $val) {
         $queuecount += $val;
     }
     return $queuecount;
 }
开发者ID:mithun12000,项目名称:yii2-queue,代码行数:13,代码来源:SqsQueue.php

示例3: getNumberMessages

 /**
  * @inheritdoc
  *
  * @throws \InvalidArgumentException
  * @throws QueueAccessException
  */
 public function getNumberMessages($queueName, Priority $priority = null)
 {
     $nbrMsg = 0;
     if (null === $priority) {
         $priorities = $this->priorityHandler->getAll();
         foreach ($priorities as $priority) {
             $nbrMsg += $this->getNumberMessages($queueName, $priority);
         }
         return $nbrMsg;
     }
     if (empty($queueName)) {
         throw new \InvalidArgumentException('Queue name empty or not defined.');
     }
     try {
         $queueUrl = $this->sqsClient->getQueueUrl(['QueueName' => $this->getQueueNameWithPrioritySuffix($queueName, $priority)])->get('QueueUrl');
         $result = $this->sqsClient->getQueueAttributes(['QueueUrl' => $queueUrl, 'AttributeNames' => ['ApproximateNumberOfMessages']]);
     } catch (SqsException $e) {
         throw new QueueAccessException('Unable to get number of messages.', 0, $e);
     }
     $result = $result->get('Attributes');
     if (!empty($result['ApproximateNumberOfMessages']) && $result['ApproximateNumberOfMessages'] > 0) {
         return $result['ApproximateNumberOfMessages'];
     }
     return 0;
 }
开发者ID:ReputationVIP,项目名称:queue-client,代码行数:31,代码来源:SQSAdapter.php

示例4: getAttributes

 public function getAttributes(array $attributeNames)
 {
     $args = ['QueueUrl' => $this->getQueueUrl()];
     if ($attributeNames) {
         /** @noinspection PhpUnusedLocalVariableInspection */
         foreach ($attributeNames as $name) {
             if (!in_array($name, self::ALL_ATTRIBUTES)) {
                 throw new \InvalidArgumentException("Unknown attribute {$name}");
             }
         }
         $args['AttributeNames'] = $attributeNames;
     } else {
         throw new \InvalidArgumentException("You must specify some attributes");
     }
     $result = $this->client->getQueueAttributes($args);
     return $result['Attributes'];
 }
开发者ID:oasmobile,项目名称:php-aws-wrappers,代码行数:17,代码来源:SqsQueue.php

示例5: size

 /**
  * Get the size of the queue.
  *
  * @param  string  $queue
  * @return int
  */
 public function size($queue = null)
 {
     return (int) $this->sqs->getQueueAttributes(['QueueUrl' => $this->getQueue($queue)])->get('ApproximateNumberOfMessages');
 }
开发者ID:davidhemphill,项目名称:framework,代码行数:10,代码来源:SqsQueue.php

示例6: getMessageCount

 public function getMessageCount($queueUrl)
 {
     $result = $this->service->getQueueAttributes(array('QueueUrl' => $queueUrl, 'AttributeNames' => array('ApproximateNumberOfMessages')));
     $messagesCount = $result->getPath('Attributes/ApproximateNumberOfMessages');
     return $messagesCount;
 }
开发者ID:sebastien-fauvel,项目名称:Amazon-Mws-Repricing,代码行数:6,代码来源:AwsSqsService.php

示例7: count

 /**
  * {@inheritDoc}
  */
 public function count()
 {
     $response = $this->client->getQueueAttributes(['QueueUrl' => $this->getUrl(), 'AttributeNames' => ['All']]);
     return (int) $response->getPath('Attributes/ApproximateNumberOfMessages');
 }
开发者ID:ronan-gloo,项目名称:qu,代码行数:8,代码来源:SqsQueue.php


注:本文中的Aws\Sqs\SqsClient::getQueueAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。