本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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'];
}
示例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');
}
示例6: getMessageCount
public function getMessageCount($queueUrl)
{
$result = $this->service->getQueueAttributes(array('QueueUrl' => $queueUrl, 'AttributeNames' => array('ApproximateNumberOfMessages')));
$messagesCount = $result->getPath('Attributes/ApproximateNumberOfMessages');
return $messagesCount;
}
示例7: count
/**
* {@inheritDoc}
*/
public function count()
{
$response = $this->client->getQueueAttributes(['QueueUrl' => $this->getUrl(), 'AttributeNames' => ['All']]);
return (int) $response->getPath('Attributes/ApproximateNumberOfMessages');
}