本文整理汇总了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);
}
示例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);
}
示例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'];
}
示例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');
}
示例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;
}
示例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;
}
示例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");
}
}
示例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;
}
示例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;
}
示例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)));
}
示例11: addQueue
public function addQueue($queueName)
{
$result = $this->service->createQueue(array('QueueName' => $queueName));
$queueUrl = $result->get('QueueUrl');
return $queueUrl;
}