本文整理汇总了PHP中Aws\Sqs\SqsClient::sendMessageBatchAsync方法的典型用法代码示例。如果您正苦于以下问题:PHP SqsClient::sendMessageBatchAsync方法的具体用法?PHP SqsClient::sendMessageBatchAsync怎么用?PHP SqsClient::sendMessageBatchAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aws\Sqs\SqsClient
的用法示例。
在下文中一共展示了SqsClient::sendMessageBatchAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doFlush
/**
* Flush a queue
*
* @param bool $async
* @return void
*/
private function doFlush(bool $async)
{
// SQS only supports batch of 10, so we need to splice like that
while (!empty($this->messages)) {
$messagesToPush = array_splice($this->messages, 0, 10);
$parameters = ['QueueUrl' => $this->url, 'Entries' => []];
foreach ($messagesToPush as $key => $message) {
$messageParameters = ['Id' => $key, 'MessageBody' => json_encode($message['body'], self::DEFAULT_JSON_FLAGS), 'DelaySeconds' => $message['options']['delay_seconds'] ?? null];
$parameters['Entries'][] = array_filter($messageParameters, function ($value) {
return $value !== null;
});
}
if ($async) {
$this->sqsClient->sendMessageBatchAsync($parameters);
} else {
$this->sqsClient->sendMessageBatch($parameters);
}
}
}