Class ReenqueueSettings


  • public class ReenqueueSettings
    extends java.lang.Object
    Settings for the task postponing strategy when the task should be brought back to the queue.
    Since:
    21.05.2019
    • Method Detail

      • getRetryType

        @Nonnull
        public ReenqueueRetryType getRetryType()
        Strategy type, which computes delay to the next processing of the same task.
        Returns:
        reenqueue retry type
      • getSequentialPlanOrThrow

        @Nonnull
        public java.util.List<java.time.Duration> getSequentialPlanOrThrow()
        Get the sequential plan of delays for task processing.

        Required when type == ReenqueueRetryType.SEQUENTIAL.

        Returns:
        Sequential plan of delays
        Throws:
        java.lang.IllegalStateException - when plan is not present.
      • getFixedDelayOrThrow

        @Nonnull
        public java.time.Duration getFixedDelayOrThrow()
        Fixed delay.

        Required when type == ReenqueueRetryType.FIXED.

        Returns:
        Fixed delay.
        Throws:
        java.lang.IllegalStateException - when fixed delay is not present.
      • getInitialDelayOrThrow

        @Nonnull
        public java.time.Duration getInitialDelayOrThrow()
        The first term of the progression to compute delays.

        Required when type == ReenqueueRetryType.ARITHMETIC or type == ReenqueueRetryType.GEOMETRIC.

        Returns:
        initial delay
        Throws:
        java.lang.IllegalStateException - when initial delay is not present.
      • getArithmeticStepOrThrow

        @Nonnull
        public java.time.Duration getArithmeticStepOrThrow()
        The difference of the arithmetic progression.

        Required when type == ReenqueueRetryType.ARITHMETIC.

        Returns:
        arithmetic step
        Throws:
        java.lang.IllegalStateException - when artithmetic step is not present.
      • getGeometricRatioOrThrow

        @Nonnull
        public java.lang.Long getGeometricRatioOrThrow()
        Denominator of the geometric progression.

        Required when type == ReenqueueRetryType.GEOMETRIC.

        Returns:
        geometric ratio
        Throws:
        java.lang.IllegalStateException - when geometric ratio is not present.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getName

        @Nonnull
        protected java.lang.String getName()
        Name of setting
        Returns:
        name
      • getDiffEvaluator

        @Nonnull
        protected java.util.function.BiFunction<ReenqueueSettings,​ReenqueueSettings,​java.lang.String> getDiffEvaluator()
        Function evaluates difference between new and old value. 1st argument - old value, 2nd argument - new value.
        Returns:
        difference between two values
      • getThis

        @Nonnull
        protected ReenqueueSettings getThis()
        Return typed reference of current object
        Returns:
        current object
      • copyFields

        protected void copyFields​(@Nonnull
                                  ReenqueueSettings newValue)
        Copy fields of new object to current object.
        Parameters:
        newValue - new value
      • setValue

        public final java.util.Optional<java.lang.String> setValue​(@Nonnull
                                                                   T newValue)
        Sets new value for current setting. Notifies observer when property is changed.
        Parameters:
        newValue - new value for setting
        Returns:
        diff between old value and new value. Returns empty object when no changes detected.
        See Also:
        DynamicSetting.registerObserver(BiConsumer)
      • registerObserver

        public final void registerObserver​(java.util.function.BiConsumer<T,​T> observer)
        Register observer to track setting changes.
        Parameters:
        observer - consumer which will be notified on property change. 1st argument - old value, 2nd argument - new value