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


PHP SqsClient::deleteMessageBatch方法代码示例

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


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

示例1: deleteMessageBatch

 protected function deleteMessageBatch($msgs)
 {
     $entries = [];
     /** @var SqsReceivedMessage $bmsg */
     foreach ($msgs as $idx => $bmsg) {
         $entries[] = ["Id" => "buf_{$idx}", "ReceiptHandle" => $bmsg->getReceiptHandle()];
     }
     $result = $this->client->deleteMessageBatch(["QueueUrl" => $this->getQueueUrl(), "Entries" => $entries]);
     if ($result['Failed']) {
         foreach ($result['Failed'] as $failed) {
             mwarning(sprintf("Deleting message failed, code = %s, id = %s, msg = %s, senderfault = %s", $failed['Code'], $failed['Id'], $failed['Message'], $failed['SenderFault']));
         }
         throw new \RuntimeException("Cannot delete some messages, consult log for more info!");
     }
 }
开发者ID:oasmobile,项目名称:php-aws-wrappers,代码行数:15,代码来源:SqsQueue.php

示例2: batchDelete

 /**
  * {@inheritDoc}
  */
 public function batchDelete(array $jobs)
 {
     // SQS can only handle up to 10 jobs, so if we have more jobs, we handle them in slices
     if (count($jobs) > 10) {
         do {
             $splicedJobs = array_splice($jobs, 0, 10);
             $this->batchDelete($splicedJobs);
         } while (count($splicedJobs) >= 10);
         return;
     }
     // SQS throws an exception if no jobs are inserted, which can happen due to the slicing method
     if (empty($jobs)) {
         return;
     }
     $parameters = array('QueueUrl' => $this->queueOptions->getQueueUrl(), 'Entries' => array());
     /** @var $job JobInterface */
     foreach ($jobs as $key => $job) {
         $jobParameters = array('Id' => $key, 'ReceiptHandle' => $job->getMetadata('receiptHandle'));
         $parameters['Entries'][] = $jobParameters;
     }
     $this->sqsClient->deleteMessageBatch($parameters);
 }
开发者ID:eoko,项目名称:SlmQueueSqs,代码行数:25,代码来源:SqsQueue.php

示例3: receiveMessages

 public function receiveMessages($queueUrl, $maximalMessages = 1)
 {
     if ($maximalMessages > 10) {
         throw new Exception('Messagenumber should be not more than 10');
     }
     $result = $this->service->receiveMessage(array('QueueUrl' => $queueUrl, 'MaxNumberOfMessages' => $maximalMessages));
     $returnMessages = array();
     $resultMessages = $result->getPath('Messages/*/Body');
     if ($resultMessages != null) {
         foreach ($resultMessages as $messageBody) {
             // Do something with the message
             //echo $messageBody;
             $returnMessages[] = $messageBody;
         }
         $entrys = array();
         $i = 0;
         foreach ($result->getPath('Messages/*/ReceiptHandle') as $receiptHandle) {
             $entrys[] = array('Id' => $i, 'ReceiptHandle' => $receiptHandle);
             $i++;
         }
         $result = $this->service->deleteMessageBatch(array('QueueUrl' => $queueUrl, 'Entries' => $entrys));
     }
     return $returnMessages;
 }
开发者ID:sebastien-fauvel,项目名称:Amazon-Mws-Repricing,代码行数:24,代码来源:AwsSqsService.php


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