當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。