亚马逊Sesthrottling - 超过最大发送率



根据本文档所说的话,如果我达到最大发送率,我会遇到错误。我的最大发送费率是每秒14封电子邮件,我试图发送100封邮件Contrenlty,所有电子邮件都到达收件人。

所以我想知道为什么亚马逊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在每日消息配额和最大发送率方面具有一定的空间或灵活性。他们没有透露哪个允许的偏差百分比,但是您肯定可以通过进行一些测试来找出答案。

相关内容

  • 没有找到相关文章

最新更新