PHP를 사용하여 명령 개체에서이 지원합니다.
SesClient 및 다른 클라이언트는 명령을 병렬로 실행할 수 있습니다.
$result = $client->sendEmail(array(
//email data
));
클라이언트 객체는 매우 강력하고 수행 및 getCommand()
및 execute()
같은 요청을 조작 할 수있는 많은 방법을 상속 :이 SES를 통해 단일 연결과 이메일을 발사하기위한 일반적인 방법이다. 간단한 해결책을 찾기까지 몇 시간이 걸렸습니다. 검색 할 올바른 것을 알아야합니다.
$commands = array();
$commands[] = $sesClient->getCommand('SendEmail', array(
//email data
));
$commands[] = $sesClient->getCommand('SendEmail', array(
//email data
));
// Execute an array of command objects to do them in parallel
$sesClient->execute($commands);
// Loop over the commands, which have now all been executed
foreach ($commands as $command) {
$result = $command->getResult();
// Do something with result
}
오류 처리를 다음의 코드를 실행함으로써 달성 될 수있다 : 예를 들면 :
use Guzzle\Service\Exception\CommandTransferException;
try {
$succeeded = $client->execute($commands);
} catch (CommandTransferException $e) {
$succeeded = $e->getSuccessfulCommands();
echo "Failed Commands:\n";
foreach ($e->getFailedCommands() as $failedCommand) {
echo $e->getExceptionForFailedCommand($failedCommand)->getMessage() . "\n";
}
}
아마존 commands feature에서 그들의 현상 가이드의 이러한 실시 예를 설명합니다.
니스! 오늘날 나는 (스레드가 아닌 여러 소비자 프로세스를 사용하여) 끝내기 때문에이 방법으로 정확하게 대답하려고했습니다. 사실, API가 주어지면이 솔루션 중 하나이거나 보낸 사람 프로그램을 API 끝점에 더 가깝게 이동시킵니다. – idrarig