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


PHP SqsClient::receiveMessage方法代码示例

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


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

示例1: receiveMessage

 /**
  * @return MessageReceivedInterface[]
  * @see https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-sqs-2012-11-05.html#receivemessage
  */
 public function receiveMessage(array $options = [])
 {
     $this->params = $this->mergeParams([], $options);
     $sqsResult = $this->awsSqsClient->receiveMessage($this->params);
     $sqsMessages = empty($sqsResult['Messages']) ? [] : $sqsResult['Messages'];
     return $this->createMessageObject($sqsMessages);
 }
开发者ID:recommerce,项目名称:queue-manager,代码行数:11,代码来源:SqsClient.php

示例2: pop

 /**
  * Pop the next job off of the queue.
  *
  * @param  string  $queue
  * @return \Illuminate\Contracts\Queue\Job|null
  */
 public function pop($queue = null)
 {
     $queue = $this->getQueue($queue);
     $response = $this->sqs->receiveMessage(['QueueUrl' => $queue, 'AttributeNames' => ['ApproximateReceiveCount']]);
     if (count($response['Messages']) > 0) {
         return new SqsJob($this->container, $this->sqs, $queue, $response['Messages'][0]);
     }
 }
开发者ID:ProgrammingPeter,项目名称:nba-schedule-api,代码行数:14,代码来源:SqsQueue.php

示例3: dequeue

 /**
  * {@inheritdoc}
  */
 public function dequeue(SerializerInterface $serializer)
 {
     $message = $this->client->receiveMessage(['QueueUrl' => $this->url])->get('Messages');
     if (count($message)) {
         return new SqsJob($this->client, $this->url, $message[0]['ReceiptHandle'], $serializer->unserialize($message[0]['Body']));
     }
     return null;
 }
开发者ID:Wandu,项目名称:Q,代码行数:11,代码来源:NullAdapter.php

示例4: pop

 /**
  * Pop the next job off of the queue.
  *
  * @param  string  $queue
  * @return \Illuminate\Queue\Jobs\Job|null
  */
 public function pop($queue = null)
 {
     $queue = $this->getQueue($queue);
     $response = $this->sqs->receiveMessage(array('QueueUrl' => $queue));
     if (count($response['Messages']) > 0) {
         return new SqsJob($this->container, $this->sqs, $queue, $response['Messages'][0]);
     }
 }
开发者ID:brucewu16899,项目名称:laravel-admin-panel,代码行数:14,代码来源:SqsQueue.php

示例5: dequeue

 public function dequeue()
 {
     $result = $this->client->receiveMessage(array('QueueUrl' => $this->queueUrl));
     $messages = $result->get('Messages');
     if (!$messages) {
         return false;
     }
     return array($messages[0]['Body'], $messages[0]['ReceiptHandle'], []);
 }
开发者ID:pekkis,项目名称:queue,代码行数:9,代码来源:AmazonSQSAdapter.php

示例6: pop

 /**
  * @inheritdoc
  */
 public function pop($queue)
 {
     $response = $this->sqs->receiveMessage(['QueueUrl' => $queue]);
     if (empty($response['Messages'])) {
         return false;
     }
     $data = reset($response['Messages']);
     return ['id' => $data['MessageId'], 'body' => $data['Body'], 'queue' => $queue, 'receipt-handle' => $data['ReceiptHandle']];
 }
开发者ID:mithun12000,项目名称:yii2-queue,代码行数:12,代码来源:SqsQueue.php

示例7: receive

 /**
  * @throws \RuntimeException
  *
  * @return MessageInterface
  */
 public function receive()
 {
     $packer = $this->getPacker();
     if (!$packer) {
         throw new \RuntimeException('Packed not defined');
     }
     $message = $this->client->receiveMessage(array('QueueUrl' => $this->queueUrl));
     return $packer->decode($message);
 }
开发者ID:oncesk,项目名称:sqs-wrapper,代码行数:14,代码来源:Manager.php

示例8: fetchJob

 /**
  * Return next job from the queue.
  * @return Job|boolean the job or false if not found.
  */
 public function fetchJob()
 {
     $message = $this->_client->receiveMessage(['QueueUrl' => $this->url, 'AttributeNames' => ['ApproximateReceiveCount'], 'MaxNumberOfMessages' => 1]);
     if (isset($message['Messages']) && count($message['Messages']) > 0) {
         return $this->createJobFromMessage($message['Messages'][0]);
     } else {
         return false;
     }
 }
开发者ID:voodoo-mobile,项目名称:yii2-queue,代码行数:13,代码来源:SqsQueue.php

示例9: receiveSqsMessage

 /**
  * @param mixed[] $args
  * @return Result
  * @throws ExceptionInterface
  */
 private function receiveSqsMessage(array $args = [])
 {
     $result = $this->sqsClient->receiveMessage($args);
     $messages = array();
     foreach ($result->search('Messages[]') as $i => $message) {
         $messages[$i] = $this->decodeSqsMessage($message);
     }
     $result->offsetSet('Messages', $messages);
     return $result;
 }
开发者ID:abacaphiliac,项目名称:aws-sdk-php-claim-check,代码行数:15,代码来源:SqsExtendedClient.php

示例10: receive

 /**
  * {@inheritDoc}
  */
 public function receive()
 {
     $result = $this->client->receiveMessage(array('QueueUrl' => $this->queueUrl));
     if (null === $result->get('Messages')) {
         return;
     }
     if ($result) {
         return new Message($result['Messages'][0]['Body'], array('ReceiptHandle' => $result['Messages'][0]['ReceiptHandle']));
     }
 }
开发者ID:dspacelabs,项目名称:queue,代码行数:13,代码来源:SqsQueue.php

示例11: pull

 /**
  * Wait and get job from a queue
  *
  * @access public
  * @return Job|null
  */
 public function pull()
 {
     $result = $this->sqsClient->receiveMessage(array('QueueUrl' => $this->sqsUrl, 'WaitTimeSeconds' => empty($this->config['LongPollingTime']) ? 0 : (int) $this->config['LongPollingTime']));
     if ($result['Messages'] == null) {
         return null;
     }
     $resultMessage = array_pop($result['Messages']);
     $job = new Job();
     $job->setId($resultMessage['ReceiptHandle']);
     $job->unserialize($resultMessage['Body']);
     return $job;
 }
开发者ID:fguillot,项目名称:simple-queue,代码行数:18,代码来源:AwsSqsQueueAdapter.php

示例12: receive

 /**
  * Receive messages
  *
  * @param bool $priority
  * @param int $num
  * @param int $wait
  * @return \Guzzle\Service\Resource\Model
  */
 public function receive($priority = false, $num = 10, $wait = 20)
 {
     if (empty($this->url)) {
         return false;
     }
     $receiveData = ['QueueUrl' => $this->url, 'MaxNumberOfMessages' => $num, 'WaitTimeSeconds' => $wait];
     if ($priority) {
         $receiveData['MessageAttributeNames'] = ["Priority"];
     }
     $result = $this->client->receiveMessage($receiveData);
     return $result->toArray();
 }
开发者ID:kameshwariv,项目名称:testexample,代码行数:20,代码来源:Sqs.php

示例13: receive

 /**
  * @param int $messagesCount
  * @return array of QueueMessage
  */
 public function receive($messagesCount = 1)
 {
     $result = $this->client->receiveMessage(['QueueUrl' => $this->queueUrl, 'WaitTimeSeconds' => 20, 'VisibilityTimeout' => 3600, 'MaxNumberOfMessages' => $messagesCount]);
     $queueUrl = $this->queueUrl;
     return array_map(function ($message) use($queueUrl) {
         $body = json_decode($message['Body']);
         if (!is_object($body)) {
             $this->client->deleteMessage(['QueueUrl' => $queueUrl, 'ReceiptHandle' => $message['ReceiptHandle']]);
             throw new ApplicationException("Corrupted message {$message['MessageId']} received. Message was deleted from SQS.", null, ['message' => $message]);
         }
         return new QueueMessage($message['MessageId'], $body, $message['ReceiptHandle'], $queueUrl);
     }, (array) $result['Messages']);
 }
开发者ID:ErikZigo,项目名称:syrup,代码行数:17,代码来源:QueueService.php

示例14: dequeue

 /**
  * @inheritDoc
  */
 public function dequeue($queueName)
 {
     $queueUrl = $this->getQueueUrl($queueName);
     $result = $this->client->receiveMessage(array('QueueUrl' => $queueUrl, 'MaxNumberOfMessages' => 1, 'AttributeNames' => ['ApproximateReceiveCount']));
     if (!$result || !($messages = $result['Messages'])) {
         return null;
     }
     $message = array_shift($messages);
     $wrapped = $this->unserialize($message['Body']);
     $msg = new DefaultEnvelope($wrapped->unwrap(), $message['Attributes']['ApproximateReceiveCount']);
     $env = new SqsEnvelope($message['MessageId'], $msg, $message['ReceiptHandle']);
     return $env;
 }
开发者ID:spekkionu,项目名称:sqs-queue-driver,代码行数:16,代码来源:SqsDriver.php

示例15: receiveMessageBatch

 /**
  * @param int   $max_count
  * @param int   $wait
  * @param int   $visibility_timeout
  * @param array $metas
  * @param array $message_attributes
  *
  * @return SqsReceivedMessage[]
  */
 protected function receiveMessageBatch($max_count = 1, $wait = null, $visibility_timeout = null, $metas = [], $message_attributes = [])
 {
     if ($max_count > 10 || $max_count < 1) {
         throw new \InvalidArgumentException("Max count for SQS message receiving is 10");
     }
     $args = ["QueueUrl" => $this->getQueueUrl(), "MaxNumberOfMessages" => $max_count];
     if ($wait !== null && is_int($wait)) {
         $args['WaitTimeSeconds'] = $wait;
     }
     if ($visibility_timeout !== null && is_int($visibility_timeout)) {
         $args['VisibilityTimeout'] = $visibility_timeout;
     }
     if ($metas && is_array($metas)) {
         $args['AttributeNames'] = $metas;
     }
     if ($message_attributes && is_array($message_attributes)) {
         $args['MessageAttributeNames'] = $message_attributes;
     }
     $result = $this->client->receiveMessage($args);
     $messages = $result['Messages'];
     if (!$messages) {
         return [];
     }
     $ret = [];
     foreach ($messages as $data) {
         $msg = new SqsReceivedMessage($data);
         $ret[] = $msg;
     }
     return $ret;
 }
开发者ID:oasmobile,项目名称:php-aws-wrappers,代码行数:39,代码来源:SqsQueue.php


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