了解AWS PHP SDK中的重试逻辑

It seems that only the DynamoDB and S3Clients have retry logic enabled.

It seems like the retries config value has no effect on other services. Is there an easy way to enable this on others (e.g. SQS), or have I misunderstood this functionality?

I've located the clientConfig.setUseThrottleRetries(true); option in the Java SDK, but have yet to find an equivalent in the PHP SDK.

You have misunderstood: SQS does have retries enabled.

To test: try the following:

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

and do not send any messages. You'll see

10

as that is #WaitTime * #retries

If you get no messages, it's considered a failure and will retry to get some.

S3 and DynamoDB have special cases - which is what you noticed.

Edit:

This works: hacking AWS code.

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

This doesn't: in my code.

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