Class FixedTaskExecutionBackOff
- java.lang.Object
-
- com.github.sonus21.rqueue.utils.backoff.FixedTaskExecutionBackOff
-
- All Implemented Interfaces:
TaskExecutionBackOff
public class FixedTaskExecutionBackOff extends java.lang.Object implements TaskExecutionBackOff
Implementation of theTaskExecutionBackOffclass, 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:
ExponentialTaskExecutionBackOff
-
-
Field Summary
Fields Modifier and Type Field Description static longDEFAULT_INTERVALThe default task delay: 5000 ms = 5 seconds.-
Fields inherited from interface com.github.sonus21.rqueue.utils.backoff.TaskExecutionBackOff
STOP
-
-
Constructor Summary
Constructors Constructor Description FixedTaskExecutionBackOff()Create an instance with an interval of 5000L ms and maximum value of retries.FixedTaskExecutionBackOff(long interval, int maxRetries)Create an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object other)longgetInterval()Return the delay between two attempts in milliseconds.intgetMaxRetries()Return the maximum number of retries.longnextBackOff(java.lang.Object object, 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 Detail
-
DEFAULT_INTERVAL
public static final long DEFAULT_INTERVAL
The default task delay: 5000 ms = 5 seconds.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
getInterval
public long getInterval()
Return the delay between two attempts in milliseconds.- Returns:
- the configured interval in milli seconds.
-
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
public long nextBackOff(java.lang.Object object, RqueueMessage rqueueMessage, int failureCount)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:
object- message that's fetchedrqueueMessage- raw messagefailureCount- number of times this message has failed.- Returns:
- backoff in the millisecond.
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
-