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 theTaskExecutionBackOff
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:
ExponentialTaskExecutionBackOff
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_INTERVAL
The 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 boolean
equals(java.lang.Object other)
long
getInterval()
Return the delay between two attempts in milliseconds.protected long
getInterval(java.lang.Object message, RqueueMessage rqueueMessage, int failureCount)
int
getMaxRetries()
Return the maximum number of retries.protected int
getMaxRetries(java.lang.Object message, RqueueMessage rqueueMessage, int failureCount)
long
nextBackOff(java.lang.Object message, RqueueMessage rqueueMessage, int failureCount)
Return the number of milliseconds to wait for the same message to be consumed by other consumers.void
setInterval(long interval)
Set the delay between two attempts in milliseconds.void
setMaxRetries(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 message, RqueueMessage rqueueMessage, int failureCount)
Description copied from interface:TaskExecutionBackOff
Return 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:
nextBackOff
in interfaceTaskExecutionBackOff
- Parameters:
message
- message that's fetchedrqueueMessage
- raw messagefailureCount
- number of times this message has failed.- Returns:
- backoff in the millisecond.
-
getMaxRetries
protected int getMaxRetries(java.lang.Object message, RqueueMessage rqueueMessage, int failureCount)
-
getInterval
protected long getInterval(java.lang.Object message, RqueueMessage rqueueMessage, int failureCount)
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
-