Created
February 27, 2019 12:02
-
-
Save dariusjs/c3e6a89b3ed02ef2d68f4398747b1ca3 to your computer and use it in GitHub Desktop.
Polly Retry Policy for Kinesis Putrecord
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pollyRetryPolicy = Policy | |
.Handle<Exception>() | |
.OrResult<PutRecordResponse>(message => !message.HttpStatusCode.Equals(HttpStatusCode.OK)) | |
.WaitAndRetryAsync( | |
5, | |
(retryAttempt) => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), | |
(result, timeSpan, retryCount, context) => { | |
logger.LogError($"Kinesis Request failed with {result}. Waiting {timeSpan} before next retry. Retry attempt {retryCount}"); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment