Class ExponentialBackOffRetryPolicy

java.lang.Object
org.axonframework.messaging.core.retry.ExponentialBackOffRetryPolicy
All Implemented Interfaces:
DescribableComponent, RetryPolicy

public class ExponentialBackOffRetryPolicy extends Object implements RetryPolicy
A RetryScheduler that uses a backoff strategy, doubling the retry delay after each attempt.
Since:
4.2
Author:
Bert Laverman, Allard Buijze
  • Constructor Details

    • ExponentialBackOffRetryPolicy

      public ExponentialBackOffRetryPolicy(long initialWaitTime)
      Initializes an exponential delay policy with given initialWaitTime in milliseconds.
      Parameters:
      initialWaitTime - the wait time for the first retry
  • Method Details

    • defineFor

      public RetryPolicy.Outcome defineFor(@Nonnull Message message, @Nonnull Throwable failure, @Nonnull List<Class<? extends Throwable>[]> previousFailures)
      Description copied from interface: RetryPolicy
      Provides the outcome for the policy given the failed message that was dispatched and resulted in given failure. The previousFailures represent a summary of previous failures that have occurred in previous attemps to send this message.
      Specified by:
      defineFor in interface RetryPolicy
      Parameters:
      message - The message that failed
      failure - The exception that occurred while dispatching
      previousFailures - a summary of all previous failures
      Returns:
      the outcome describing the expected rescheduling behavior
    • describeTo

      public void describeTo(@Nonnull ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.

      Best Practices: As a general rule, all relevant fields of a DescribableComponent implementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing the describeTo method, who should focus on providing information that is useful for understanding the component's configuration and state.

      Example implementation:

       public void describeTo(ComponentDescriptor descriptor) {
           descriptor.describeProperty("name", this.name);
           descriptor.describeProperty("enabled", this.enabled);
           descriptor.describeProperty("configuration", this.configuration); // A nested component
           descriptor.describeProperty("handlers", this.eventHandlers);      // A collection
       }
       
      Specified by:
      describeTo in interface DescribableComponent
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.