com.alarmpoint.integrationagent.exceptions.retriable

## Class MaxAttemptRetryPolicy

- java.lang.Object
- - com.alarmpoint.integrationagent.exceptions.retriable.AbstractRetryPolicy
  - - com.alarmpoint.integrationagent.exceptions.retriable.MaxAttemptRetryPolicy

- All Implemented Interfaces:
    DelayPolicy, RetryPolicy

      public class MaxAttemptRetryPolicy
      extends AbstractRetryPolicy

  A retry policy that enforces a maximum number of retry attempts and a customizable delay between attempts.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MaxAttemptRetryPolicy(int maxAttempts, DelayPolicy delayPolicy)` Default constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isRetriable(int numAttempts, long firstAttemptTimestamp)` Determines whether a retry should be attempted.
    `java.lang.String` | `toString()` Returns a string of the form: "Up to 3 attempts, 10 seconds between each attempt."

    - ### Methods inherited from class com.alarmpoint.integrationagent.exceptions.retriable.AbstractRetryPolicy

      `getDelay`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### MaxAttemptRetryPolicy

          public MaxAttemptRetryPolicy(int maxAttempts,
                                       DelayPolicy delayPolicy)

      Default constructor.
      Parameters:
        `maxAttempts` - - the maximum number of attempts (first attempt and retries) that will be allowed; must be >= 1
        `delayPolicy` - - the policy for computing delays between attempts; must be non-null

  - ### Method Detail

    - #### isRetriable

          public boolean isRetriable(int numAttempts,
                                     long firstAttemptTimestamp)

      Determines whether a retry should be attempted.
      Parameters:
        `numAttempts` - - the number of previous attempts (including first attempt and previous retries); assumed to be equal or more than 1
        `firstAttemptTimestamp` - - the timestamp (milliseconds since epoch) of the first attempt to process the message; may be less than 0 if information not available
      Returns:
        `true` if a retry should be attempted; otherwise, `false`

    - #### toString

          public java.lang.String toString()

      Returns a string of the form: "Up to 3 attempts, 10 seconds between each attempt."
      Specified by:
        `toString` in interface `DelayPolicy`
      Overrides:
        `toString` in class `AbstractRetryPolicy`