當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。