Package org.camunda.bpm.client.backoff
Class ExponentialErrorBackoffStrategy
- java.lang.Object
-
- org.camunda.bpm.client.backoff.ExponentialErrorBackoffStrategy
-
- All Implemented Interfaces:
BackoffStrategy
,ErrorAwareBackoffStrategy
public class ExponentialErrorBackoffStrategy extends Object implements ErrorAwareBackoffStrategy
Provides an exponential backoff strategy when an error occurs fetching external tasks.
Note this strategy does not provide any backoff when no external tasks are received. It should therefore only be used with long polling (asyncResponseTimeout) to ensure appropriate throttling of requests.
-
-
Constructor Summary
Constructors Constructor Description ExponentialErrorBackoffStrategy()
ExponentialErrorBackoffStrategy(long initTime, float factor, long maxTime)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
calculateBackoffTime()
Calculates the back off time and is invoked afterErrorAwareBackoffStrategy.reconfigure(List, ExternalTaskClientException)
.void
reconfigure(List<ExternalTask> externalTasks, ExternalTaskClientException error)
Reconfigures the back off strategy based on the fetched external tasks and any error that might have occurred.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.camunda.bpm.client.backoff.ErrorAwareBackoffStrategy
reconfigure
-
-
-
-
Constructor Detail
-
ExponentialErrorBackoffStrategy
public ExponentialErrorBackoffStrategy()
-
ExponentialErrorBackoffStrategy
public ExponentialErrorBackoffStrategy(long initTime, float factor, long maxTime)
- Parameters:
initTime
- in milliseconds for which the client is suspended after the first requestfactor
- is the base of the power by which the waiting time increasesmaxTime
- in milliseconds for which the client can be suspended
-
-
Method Detail
-
reconfigure
public void reconfigure(List<ExternalTask> externalTasks, ExternalTaskClientException error)
Description copied from interface:ErrorAwareBackoffStrategy
Reconfigures the back off strategy based on the fetched external tasks and any error that might have occurred. It is invoked before
ErrorAwareBackoffStrategy.calculateBackoffTime()
.The implementation might count the amount of invocations and realize a strategy reset.
- Specified by:
reconfigure
in interfaceErrorAwareBackoffStrategy
- Parameters:
externalTasks
- which have been fetchederror
- can be of the following types:EngineException
if something went wrong during the engine execution (e.g., a persistence exception occurred).BadRequestException
if an illegal operation was performed or the given data is invalid.ConnectionLostException
if the connection could not be established.UnknownHttpErrorException
if the HTTP status code is not known by the client.
-
calculateBackoffTime
public long calculateBackoffTime()
Description copied from interface:ErrorAwareBackoffStrategy
Calculates the back off time and is invoked after
ErrorAwareBackoffStrategy.reconfigure(List, ExternalTaskClientException)
.- Specified by:
calculateBackoffTime
in interfaceBackoffStrategy
- Specified by:
calculateBackoffTime
in interfaceErrorAwareBackoffStrategy
- Returns:
- the back off time between fetch and lock requests in milliseconds
-
-