0
按照documentation的說法,如果達到最大發送速率,我會收到錯誤消息。我的最大發送速率是每秒14封電子郵件,並且我試圖發送100封郵件同意書,所有電子郵件都發送給收件人。Amazon sesThrottling - 超過最大發送速率
所以我不知道爲什麼亞馬遜SES沒有發「信號」抱怨我多餘的或更容易,爲什麼亞馬遜SES沒有提供所有的100封郵件時,它應該只發送14
這裏是我使用的代碼:
List<String> destinations = new ArrayList<>(); //replace with your TO email addresses
for (int i = 0; i < 100; i++) {
destinations.add("Receiver address");
}
int i=0;
for (String destination : destinations) {
new Thread("" + i){
public void run(){
System.out.println("Thread: " + getName() + " running");
int maxRetries = 10;
while(maxRetries-->0) {
try {
// Create the subject and body of the message.
Content subject = new Content().withData("Asunto");
Content textBody = new Content().withData("cuerpo");
Body body = new Body().withText(textBody);
// Create a message with the specified subject and body.
Message message = new Message().withSubject(subject).withBody(body);
Destination destination2 = new Destination().withToAddresses(new String[]{destination});
// Assemble the email.
SendEmailRequest request = new SendEmailRequest().withSource("fromnaddres").withDestination(destination2).withMessage(message);
//wait for a permit to become available
//rateLimiter.acquire();
//call Amazon SES to send the message
SendEmailResult result = client.sendEmail(request);
System.out.println("sent "+result.getMessageId());
break;
} catch (AmazonServiceException e) {
//retries only throttling errors
System.out.println("hola");
if ("Throttling".equals(e.getErrorCode()) && "Maximum sending rate exceeded.".equals(e.getMessage())) {
System.out.println("Maximum send rate exceeded when sending email to "+destination+". "
+(maxRetries>1?"Will retry.":"Will not retry."));
} else {
System.out.println("Unable to send email to: "+destination+". " +e.toString());
break;
}
} catch(Exception e) {
System.out.println("Unable to send email to: "+destination+". " +e.toString());
break;
}
}
}
}.start();
i++;
}
那麼你的問題是什麼? – alexandresaiz
在你沒有達到你的限制的任何時期之後,可能會有一個小的突發津貼。 * [需要的引證] * –
@alexandresaiz問題是,我無法測試最大發送率情況下的行爲 –