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


PHP SqsClient::setQueueAttributes方法代码示例

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


在下文中一共展示了SqsClient::setQueueAttributes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 /**
  * {@inheritDoc}
  */
 public function update(QueueAdapterInterface $queue)
 {
     if (!$queue instanceof SqsQueue) {
         throw new InvalidArgumentException('expecting an instance of SqsQueue');
     }
     // Update queue attributes if required
     $Attributes = $queue->getConfig()->toAttributes();
     $QueueUrl = $queue->getUrl();
     $this->client->setQueueAttributes(compact('QueueUrl', 'Attributes'));
 }
开发者ID:ronan-gloo,项目名称:qu,代码行数:13,代码来源:SqsQueueManager.php

示例2: createQueue

 /**
  * Creates an SQS Queue and returns the Queue Url
  *
  * The create method for SQS Queues is idempotent - if the queue already
  * exists, this method will return the Queue Url of the existing Queue.
  *
  * @return string
  */
 public function createQueue()
 {
     $result = $this->sqs->createQueue(['QueueName' => $this->getNameWithPrefix(), 'Attributes' => ['VisibilityTimeout' => $this->options['message_timeout'], 'MessageRetentionPeriod' => $this->options['message_expiration'], 'ReceiveMessageWaitTimeSeconds' => $this->options['receive_wait_time']]]);
     $this->queueUrl = $result->get('QueueUrl');
     $key = $this->getNameWithPrefix() . '_url';
     $this->cache->save($key, $this->queueUrl);
     $this->log(200, "Created SQS Queue", ['QueueUrl' => $this->queueUrl]);
     if ($this->options['push_notifications']) {
         $policy = $this->createSqsPolicy();
         $this->sqs->setQueueAttributes(['QueueUrl' => $this->queueUrl, 'Attributes' => ['Policy' => $policy]]);
         $this->log(200, "Created Updated SQS Policy");
     }
 }
开发者ID:uecode,项目名称:qpush-bundle,代码行数:21,代码来源:AwsProvider.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $noWatch = $input->getOption('no-watch');
     $queueId = $this->getQueueId();
     $snsConfig = $this->getContainer()->getParameter('sns');
     $region = isset($snsConfig['region']) ? $snsConfig['region'] : 'us-east-1';
     /** @var QueueFactory $queueFactory */
     $queueFactory = $this->getContainer()->get('syrup.queue_factory');
     $sqs = $queueFactory->create($queueId, $region, $snsConfig['key'], $snsConfig['secret']);
     /** @var Connection $conn */
     $conn = $this->getContainer()->get('doctrine.dbal.syrup_connection');
     $stmt = $conn->query("SELECT * FROM queues WHERE id='{$queueId}'");
     $res = $stmt->fetchAll();
     if (empty($res)) {
         $conn->insert('queues', ['id' => $queueId, 'access_key' => $snsConfig['key'], 'secret_key' => $snsConfig['secret'], 'region' => $region, 'url' => $sqs->get('QueueUrl')]);
     }
     $sqsClient = new SqsClient(['region' => $region, 'version' => '2012-11-05', 'credentials' => ['key' => $snsConfig['key'], 'secret' => $snsConfig['secret']]]);
     $sqsArn = $sqsClient->getQueueArn($sqs->get('QueueUrl'));
     // subscribe SQS to SNS
     $snsClient = new SnsClient(['region' => $region, 'version' => '2010-03-31', 'credentials' => ['key' => $snsConfig['key'], 'secret' => $snsConfig['secret']]]);
     $snsClient->subscribe(['TopicArn' => $snsConfig['topic_arn'], 'Protocol' => 'sqs', 'Endpoint' => $sqsArn]);
     // add policy to SQS to allow SNS sending messages to it
     $sqsPolicy = '{
       "Version": "2008-10-17",
       "Id": "' . $sqsArn . '/SQSDefaultPolicy",
       "Statement": [
         {
           "Sid": "sqs-sns",
           "Effect": "Allow",
           "Principal": {
             "AWS": "*"
           },
           "Action": "SQS:SendMessage",
           "Resource": "' . $sqsArn . '",
           "Condition": {
             "ArnEquals": {
               "aws:SourceArn": "' . $snsConfig['topic_arn'] . '"
             }
           }
         }
       ]
     }';
     $sqsClient->setQueueAttributes(['QueueUrl' => $sqs->get('QueueUrl'), 'Attributes' => ['Policy' => $sqsPolicy]]);
     $output->writeln("SQS created and registered to SNS");
     // Add Cloudwatch alarm
     if (!$noWatch) {
         $cwClient = new CloudWatchClient(['region' => $region, 'version' => '2010-08-01', 'credentials' => ['key' => $snsConfig['key'], 'secret' => $snsConfig['secret']]]);
         $cwClient->putMetricAlarm(['AlarmName' => sprintf('Syrup %s queue is full', $queueId), 'ActionsEnabled' => true, 'AlarmActions' => [$snsConfig['alarm_topic_arn']], 'MetricName' => 'ApproximateNumberOfMessagesVisible', 'Namespace' => 'AWS/SQS', 'Statistic' => 'Average', 'Dimensions' => [['Name' => 'QueueName', 'Value' => $queueId]], 'Period' => 300, 'EvaluationPeriods' => 1, 'Threshold' => 5, 'ComparisonOperator' => 'GreaterThanOrEqualToThreshold']);
         $output->writeln("Cloudwatch alarm created");
     }
 }
开发者ID:keboola,项目名称:syrup-queue,代码行数:51,代码来源:InitKillQueueCommand.php

示例4: setAttributes

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

示例5: createQueue

 private function createQueue()
 {
     $result = $this->client->createQueue(array('QueueName' => $this->queueName));
     $this->queueUrl = $result->get('QueueUrl');
     $this->client->setQueueAttributes(array('QueueUrl' => $this->queueUrl, 'Attributes' => array('VisibilityTimeout' => $this->visibilityTimeout)));
 }
开发者ID:pekkis,项目名称:queue,代码行数:6,代码来源:AmazonSQSAdapter.php


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