Class FixedTaskExecutionBackOff
java.lang.Object
com.github.sonus21.rqueue.utils.backoff.FixedTaskExecutionBackOff
- All Implemented Interfaces:
TaskExecutionBackOff
Implementation of the
TaskExecutionBackOff class, that always return the same value,
except if number of failures have increased too high.
Default delay for the task is 5 seconds, and maximum number of retries is 2147483647.
There's another implementation of this, that provides exponential delay.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe default task delay: 5000 ms = 5 seconds.Fields inherited from interface com.github.sonus21.rqueue.utils.backoff.TaskExecutionBackOff
STOP -
Constructor Summary
ConstructorsConstructorDescriptionCreate an instance with an interval of 5000L ms and maximum value of retries.FixedTaskExecutionBackOff(long interval, int maxRetries) Create an instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanlongReturn the delay between two attempts in milliseconds.protected longgetInterval(Object message, RqueueMessage rqueueMessage, int failureCount) intReturn the maximum number of retries.protected intgetMaxRetries(Object message, RqueueMessage rqueueMessage, int failureCount) longnextBackOff(Object message, RqueueMessage rqueueMessage, int failureCount) Return the number of milliseconds to wait for the same message to be consumed by other consumers.voidsetInterval(long interval) Set the delay between two attempts in milliseconds.voidsetMaxRetries(int maxRetries) Set the maximum number of retries
-
Field Details
-
DEFAULT_INTERVAL
public static final long DEFAULT_INTERVALThe default task delay: 5000 ms = 5 seconds.- See Also:
-
-
Constructor Details
-
FixedTaskExecutionBackOff
public FixedTaskExecutionBackOff()Create an instance with an interval of 5000L ms and maximum value of retries. -
FixedTaskExecutionBackOff
public FixedTaskExecutionBackOff(long interval, int maxRetries) Create an instance.- Parameters:
interval- the delay between two attempts.maxRetries- the maximum number of retries.
-
-
Method Details
-
getInterval
public long getInterval()Return the delay between two attempts in milliseconds.- Returns:
- the configured interval in milliseconds.
-
setInterval
public void setInterval(long interval) Set the delay between two attempts in milliseconds.- Parameters:
interval- delay between two attempts.
-
getMaxRetries
public int getMaxRetries()Return the maximum number of retries.- Returns:
- max retires
-
setMaxRetries
public void setMaxRetries(int maxRetries) Set the maximum number of retries- Parameters:
maxRetries- max number of retires
-
nextBackOff
Description copied from interface:TaskExecutionBackOffReturn the number of milliseconds to wait for the same message to be consumed by other consumers. (-1L) to indicate that no further enqueue should be made for the message.- Specified by:
nextBackOffin interfaceTaskExecutionBackOff- Parameters:
message- message that's fetchedrqueueMessage- raw messagefailureCount- number of times this message has failed.- Returns:
- backoff in the millisecond.
-
getMaxRetries
-
getInterval
-
equals
-