Package com.yahoo.messagebus.routing
Class RetryTransientErrorsPolicy
java.lang.Object
com.yahoo.messagebus.routing.RetryTransientErrorsPolicy
- All Implemented Interfaces:
RetryPolicy
Implements a retry policy that allows resending of any error that is not fatal. It also does progressive back-off,
delaying each attempt by the given time multiplied by the retry attempt.
- Author:
- Simon Thoresen Hult
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canRetry
(int errorCode) double
getRetryDelay
(int retry) Returns the number of seconds to delay resending a message.setBaseDelay
(double baseDelay) Sets the base delay in seconds to wait between retries.setEnabled
(boolean enabled) Sets whether or not this policy should allow retries or not.
-
Constructor Details
-
RetryTransientErrorsPolicy
public RetryTransientErrorsPolicy()
-
-
Method Details
-
setEnabled
Sets whether or not this policy should allow retries or not.- Parameters:
enabled
- True to allow retries.- Returns:
- This, to allow chaining.
-
setBaseDelay
Sets the base delay in seconds to wait between retries. This amount is multiplied by the retry number.- Parameters:
baseDelay
- The time in seconds.- Returns:
- This, to allow chaining.
-
canRetry
public boolean canRetry(int errorCode) Description copied from interface:RetryPolicy
Returns whether or not aReply
containing anError
with the given error code can be retried. This method is invoked once for each error in a reply.- Specified by:
canRetry
in interfaceRetryPolicy
- Parameters:
errorCode
- The code to check.- Returns:
- True if the message can be resent.
-
getRetryDelay
public double getRetryDelay(int retry) Description copied from interface:RetryPolicy
Returns the number of seconds to delay resending a message.- Specified by:
getRetryDelay
in interfaceRetryPolicy
- Parameters:
retry
- The retry attempt.- Returns:
- The delay in seconds.
-