gpt4 book ai didi

java - Amazon sesThrotdling – 超出最大发送速率

转载 作者:行者123 更新时间:2023-12-01 18:14:57 25 4
gpt4 key购买 nike

据此 documentation说,如果我达到最大发送速率,我会收到错误。我的最大发送速率是每秒 14 封电子邮件,我尝试同时发送 100 封邮件,所有电子邮件均到达收件人。

所以我想知道为什么 Amazon SES 没有发送任何“信号”来提示我的过度或更容易,为什么 Amazon SES 在本应只发送 14 封电子邮件时却发送了所有这 100 封电子邮件。

这是我使用的代码:

    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++;
}

最佳答案

Amazon SES 在每日消息配额和最大发送速率方面提供了一定的空间或灵 active 。他们没有透露允许的偏差百分比是多少,但你绝对可以通过做一些测试来找出答案。

关于java - Amazon sesThrotdling – 超出最大发送速率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30227368/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com