Class RetrySimulator

java.lang.Object
org.springframework.retry.support.RetrySimulator

public class RetrySimulator extends Object
A RetrySimulator is a tool for exercising retry + backoff operations. When calibrating a set of retry + backoff pairs, it is useful to know the behaviour of the retry for various scenarios. Things you may want to know: - Does a 'maxInterval' of 5000 ms in my backoff even matter? (This is often the case when retry counts are low -- so why set the max interval at something that cannot be achieved?) - What are the typical sleep durations for threads in a retry - What was the longest sleep duration for any retry sequence The simulator provides this information by executing a retry + backoff pair until failure (that is all retries are exhausted). The information about each retry is provided as part of the RetrySimulation. Note that the impetus for this class was to expose the timings which are possible with ExponentialRandomBackOffPolicy, which provides random values and must be looked at over a series of trials.
Author:
Jon Travis
  • Constructor Details

  • Method Details

    • executeSimulation

      public RetrySimulation executeSimulation(int numSimulations)
      Execute the simulator for a give # of iterations.
      Parameters:
      numSimulations - Number of simulations to run
      Returns:
      the outcome of all simulations
    • executeSingleSimulation

      public List<Long> executeSingleSimulation()
      Execute a single simulation
      Returns:
      The sleeps which occurred within the single simulation.