【问题标题】:Understanding retry logic in the AWS PHP SDK了解 AWS PHP 开发工具包中的重试逻辑
【发布时间】:2018-07-07 22:05:02
【问题描述】:

似乎只有 DynamoDB 和 S3Clients 有retry logic enabled

似乎retries 配置值对其他服务没有影响。是否有一种简单的方法可以在其他人(例如 SQS)上启用此功能,还是我误解了此功能?

我在 Java SDK 中找到了 clientConfig.setUseThrottleRetries(true); option,但在 PHP SDK 中还没有找到对应的。

【问题讨论】:

    标签: php amazon-web-services aws-sdk aws-php-sdk


    【解决方案1】:

    您误会了:SQS 确实启用了重试。

    测试:尝试以下方法:

    $sqsClient = new sqqClient('2012-11-05', ['retries' => 2]);
    $startTime = time();
    try {
        $sqsClient->receiveMessages(['WaitTimeSeconds' => 5]);
    } catch(Exception $e) {
    }
    $timeTaken = time() - $startTime;
    echo $timeTaken;
    

    并且不要发送任何消息。你会看到

    10
    

    那是#WaitTime * #retries

    如果您没有收到任何消息,则将其视为失败,并会重试获取一些消息。

    S3 和 DynamoDB 有特殊情况 - 这是您注意到的。

    编辑:

    这很有效:破解 AWS 代码。

    class final class Middleware
    {
    
        public static function retry(
            callable $decider = null,
            callable $delay = null,
                     $stats = false
        ) {
    
        echo 'Forcing retries to false';
        $decider = function() {return false;};
        ...
    

    这不是:在我的代码中。

    $decider = function() {
         echo 'No retries';
         return false;
    };
    $client->getHandlerList()->appendSign(\AWS\Middleware::retry($decider, null), 'retry');
    

    【讨论】:

      猜你喜欢
      • 2014-12-22
      • 1970-01-01
      • 1970-01-01
      • 2015-05-29
      • 2017-08-02
      • 2015-10-17
      • 1970-01-01
      • 2015-08-18
      • 2017-08-02
      相关资源
      最近更新 更多