Package com.yahoo.messagebus.routing
Class RetryTransientErrorsPolicy
- java.lang.Object
-
- com.yahoo.messagebus.routing.RetryTransientErrorsPolicy
-
- All Implemented Interfaces:
RetryPolicy
public class RetryTransientErrorsPolicy extends java.lang.Object implements 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
Constructors Constructor Description RetryTransientErrorsPolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRetry(int errorCode)
double
getRetryDelay(int retry)
Returns the number of seconds to delay resending a message.RetryTransientErrorsPolicy
setBaseDelay(double baseDelay)
Sets the base delay in seconds to wait between retries.RetryTransientErrorsPolicy
setEnabled(boolean enabled)
Sets whether or not this policy should allow retries or not.
-
-
-
Method Detail
-
setEnabled
public RetryTransientErrorsPolicy setEnabled(boolean enabled)
Sets whether or not this policy should allow retries or not.- Parameters:
enabled
- True to allow retries.- Returns:
- This, to allow chaining.
-
setBaseDelay
public RetryTransientErrorsPolicy setBaseDelay(double baseDelay)
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.
-
-