當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SqsClient::createQueue方法代碼示例

本文整理匯總了PHP中Aws\Sqs\SqsClient::createQueue方法的典型用法代碼示例。如果您正苦於以下問題:PHP SqsClient::createQueue方法的具體用法?PHP SqsClient::createQueue怎麽用?PHP SqsClient::createQueue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Aws\Sqs\SqsClient的用法示例。


在下文中一共展示了SqsClient::createQueue方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createQueue

 /**
  * {@inheritDoc}
  */
 public function createQueue($queueId, $options = [])
 {
     $timeout = empty($options["messageLockTimeout"]) || !is_numeric($options["messageLockTimeout"]) ? self::DEFAULT_MESSAGE_LOCK_TIMEOUT : (int) $options["messageLockTimeout"];
     $attributes = ["VisibilityTimeout" => $timeout];
     $this->queueClient->createQueue(["QueueName" => $queueId, "Attributes" => $attributes]);
     $this->setQueueId($queueId);
 }
開發者ID:silktide,項目名稱:queueball-sqs,代碼行數:10,代碼來源:Queue.php

示例2: create

 /**
  * {@inheritDoc}
  */
 public function create($options)
 {
     if (!$options instanceof SqsQueueConfig) {
         throw new InvalidArgumentException('$options cannot be used to create a new queue');
     }
     // SQS is resilient when creating a new queue, only if attributes are similar
     try {
         $this->client->createQueue(['QueueName' => $this->prepareQueueName($options->getName()), 'Attributes' => $options->toAttributes()]);
     } catch (\Exception $e) {
         throw new RuntimeException('Cannot create the queue with name ' . $options->getName(), $e->getCode(), $e);
     }
     $options->setAccountId($this->config->getAccountId());
     return new SqsQueue($this->client, $options);
 }
開發者ID:ronan-gloo,項目名稱:qu,代碼行數:17,代碼來源:SqsQueueManager.php

示例3: createQueue

 public function createQueue(array $attributes = [])
 {
     $args = ['QueueName' => $this->name];
     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;
     }
     $result = $this->client->createQueue($args);
     $this->url = $result['QueueUrl'];
 }
開發者ID:oasmobile,項目名稱:php-aws-wrappers,代碼行數:15,代碼來源:SqsQueue.php

示例4: __construct

 /**
  * Create new Amazon SQS driver.
  *
  * You have to create aws client instnace and provide it to this driver.
  * You can use service builder or factory method.
  *
  * <code>
  *  use Aws\Sqs\SqsClient;
  *
  *  $client = SqsClient::factory(array(
  *    'profile' => '<profile in your aws credentials file>',
  *    'region'  => '<region name>'
  *  ));
  * </code>
  *
  * or
  *
  * <code>
  * use Aws\Common\Aws;
  *
  * // Create a service builder using a configuration file
  * $aws = Aws::factory('/path/to/my_config.json');
  *
  * // Get the client from the builder by namespace
  * $client = $aws->get('Sqs');
  * </code>
  *
  * More examples see: https://docs.aws.amazon.com/aws-sdk-php/v2/guide/service-sqs.html
  *
  *
  * @see examples/sqs folder
  *
  * @param SqsClient     $client
  * @param string        $queueName
  * @param array         $queueAttributes
  */
 public function __construct(SqsClient $client, $queueName, $queueAttributes = [])
 {
     $this->client = $client;
     $this->queueName = $queueName;
     $this->serializer = new MessageSerializer();
     $result = $client->createQueue(['QueueName' => $queueName, 'Attributes' => $queueAttributes]);
     $this->queueUrl = $result->get('QueueUrl');
 }
開發者ID:tomaj,項目名稱:hermes,代碼行數:44,代碼來源:AmazonSqsDriver.php

示例5: create

 public function create($name, $region = 'us-east-1', $key = null, $secret = null)
 {
     $data = ['region' => $region, 'version' => '2012-11-05', 'retries' => 40];
     if ($key != null && $secret != null) {
         $data['credentials'] = ['key' => $key, 'secret' => $secret];
     }
     $sqsClient = new SqsClient($data);
     $sqsQueue = $sqsClient->createQueue(['QueueName' => $name]);
     return $sqsQueue;
 }
開發者ID:ErikZigo,項目名稱:syrup,代碼行數:10,代碼來源:QueueFactory.php

示例6: createQueue

 /**
  * @inheritdoc
  *
  * @throws SqsException
  */
 public function createQueue($queueName)
 {
     if (empty($queueName)) {
         throw new InvalidArgumentException('Parameter queueName empty or not defined.');
     }
     $priorities = $this->priorityHandler->getAll();
     foreach ($priorities as $priority) {
         $this->sqsClient->createQueue(['QueueName' => $this->getQueueNameWithPrioritySuffix($queueName, $priority), 'Attributes' => []]);
     }
     return $this;
 }
開發者ID:bobey,項目名稱:queue-client,代碼行數:16,代碼來源:SQSAdapter.php

示例7: 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

示例8: createQueue

 /**
  * @inheritdoc
  *
  * @throws \InvalidArgumentException
  * @throws QueueAccessException
  */
 public function createQueue($queueName)
 {
     if (empty($queueName)) {
         throw new \InvalidArgumentException('Queue name empty or not defined.');
     }
     $priorities = $this->priorityHandler->getAll();
     foreach ($priorities as $priority) {
         try {
             $this->sqsClient->createQueue(['QueueName' => $this->getQueueNameWithPrioritySuffix($queueName, $priority), 'Attributes' => []]);
         } catch (SqsException $e) {
             throw new QueueAccessException('Cannot create queue', 0, $e);
         }
     }
     return $this;
 }
開發者ID:ReputationVIP,項目名稱:queue-client,代碼行數:21,代碼來源:SQSAdapter.php

示例9: testSubscribesToTopic

 /**
  * @depends testCreatesTopic
  */
 public function testSubscribesToTopic($topicArn)
 {
     // Create an SQS queue for the test
     self::log('Creating a SQS queue');
     $result = $this->sqs->createQueue(array('QueueName' => self::$queueName));
     self::$queueUrl = $result['QueueUrl'];
     $queueArn = $this->sqs->getQueueArn(self::$queueUrl);
     // Subscribe to the SNS topic using an SQS queue
     self::log('Subscribing to the topic using the queue');
     $result = $this->sns->subscribe(array('TopicArn' => self::$topicArn, 'Endpoint' => $queueArn, 'Protocol' => 'sqs'));
     // Ensure that the result has a SubscriptionArn
     self::log('Subscribe result: ' . var_export($result->toArray(), true));
     $this->assertArrayHasKey('SubscriptionArn', $result->toArray());
     self::$subscriptionArn = $result['SubscriptionArn'];
     return self::$subscriptionArn;
 }
開發者ID:njbhatt18,項目名稱:Amazon_API,代碼行數:19,代碼來源:IntegrationTest.php

示例10: 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

示例11: addQueue

 public function addQueue($queueName)
 {
     $result = $this->service->createQueue(array('QueueName' => $queueName));
     $queueUrl = $result->get('QueueUrl');
     return $queueUrl;
 }
開發者ID:sebastien-fauvel,項目名稱:Amazon-Mws-Repricing,代碼行數:6,代碼來源:AwsSqsService.php


注:本文中的Aws\Sqs\SqsClient::createQueue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。