Class DefaultRetryPolicyProvider

  • All Implemented Interfaces:
    RetryPolicyProvider

    public class DefaultRetryPolicyProvider
    extends Object
    implements RetryPolicyProvider
    A simple implementation of RetryPolicyProvider that 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 Detail

      • DefaultRetryPolicyProvider

        public DefaultRetryPolicyProvider​(net.toddm.cache.LoggingProvider loggingProvider)
        Returns an instance of DefaultRetryPolicyProvider.
        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 the CommManager when network request work results in an exception. The RetryProfile instance 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 Exception is a type that may be caused by transiient network blips then this implementation recommends retry after a short 3 second interval.

        Specified by:
        shouldRetry in interface RetryPolicyProvider
        Parameters:
        work - The Work that resulted in the given Exception.
        error - The Exception thrown while attempting the given Request work.
        Returns:
        A RetryProfile instance used to determine if and how the request should be retried.
      • shouldRetry

        public RetryProfile shouldRetry​(Work work,
                                        Response response)
        Called by the CommManager when network request work results in a response back from the remote resource. The RetryProfile instance 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:
        shouldRetry in interface RetryPolicyProvider
        Parameters:
        work - The Work that resulted in the given Response.
        response - The Response instance resulting from the given Request work.
        Returns:
        A RetryProfile instance used to determine if and how the request should be retried.