Package net.toddm.comm
Class DefaultRetryPolicyProvider
- java.lang.Object
-
- net.toddm.comm.DefaultRetryPolicyProvider
-
- All Implemented Interfaces:
RetryPolicyProvider
public class DefaultRetryPolicyProvider extends Object implements RetryPolicyProvider
A simple implementation ofRetryPolicyProviderthat provides basic support for 503 and 202 based retries and error retries for a sub-set of exceptions where attempting the request again later seems to make sense.- Author:
- Todd S. Murchison
-
-
Constructor Summary
Constructors Constructor Description DefaultRetryPolicyProvider(net.toddm.cache.LoggingProvider loggingProvider)Returns an instance ofDefaultRetryPolicyProvider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RetryProfileshouldRetry(Work work, Exception error)Called by theCommManagerwhen network request work results in an exception.RetryProfileshouldRetry(Work work, Response response)Called by theCommManagerwhen network request work results in a response back from the remote resource.
-
-
-
Constructor Detail
-
DefaultRetryPolicyProvider
public DefaultRetryPolicyProvider(net.toddm.cache.LoggingProvider loggingProvider)
Returns an instance ofDefaultRetryPolicyProvider.- Parameters:
loggingProvider- OPTIONAL If NULL no logging callbacks are made otherwise the provided implementation will get log messages.
-
-
Method Detail
-
shouldRetry
public RetryProfile shouldRetry(Work work, Exception error)
Called by theCommManagerwhen network request work results in an exception. TheRetryProfileinstance returned is used to determine if and how the request should be retried.This implementation provides basic support for rapid Exception based retry. If the provided
Exceptionis a type that may be caused by transiient network blips then this implementation recommends retry after a short 3 second interval.- Specified by:
shouldRetryin interfaceRetryPolicyProvider- Parameters:
work- TheWorkthat resulted in the givenException.error- TheExceptionthrown while attempting the givenRequestwork.- Returns:
- A
RetryProfileinstance used to determine if and how the request should be retried.
-
shouldRetry
public RetryProfile shouldRetry(Work work, Response response)
Called by theCommManagerwhen network request work results in a response back from the remote resource. TheRetryProfileinstance returned is used to determine if and how the request should be retried.This implementation provides basic support for 503 and 202 response codes. If no 'Retry-After' header is found a default retry interval of 5 seconds is used.
- Specified by:
shouldRetryin interfaceRetryPolicyProvider- Parameters:
work- TheWorkthat resulted in the givenResponse.response- TheResponseinstance resulting from the givenRequestwork.- Returns:
- A
RetryProfileinstance used to determine if and how the request should be retried.
-
-