- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Defines delay for next read/poll operation in a polling
publisher.
Schema defines a delay before next poll if the last one did not get new data.
It is possible to use included static factory methods for some standard schemas.
-
Method Summary
Modifier and TypeMethodDescriptionstatic RetrySchemaconstant(long delay) Creates the retry schema with a constant result.static RetrySchemageometric(long firstDelay, double ratio, long maxDelay) Creates the retry schema as a bounded geometric series.static RetrySchemalinear(long firstDelay, long delayIncrement, long maxDelay) Creates the retry schema with a linear delay increment.longnextDelay(int retryCount, long lastDelay) Returns a delay before next read if the last one poll did not get new data.
-
Method Details
-
nextDelay
long nextDelay(int retryCount, long lastDelay) Returns a delay before next read if the last one poll did not get new data.- Parameters:
retryCount- a count of already poll retries. It is0when called first time and resets every time when poll returns some data.lastDelay- a last returned value.0in first call. Resets when some data are get.- Returns:
- a delay in milliseconds before next poll attempt. If less then zero then
Publishercompletes withonErrormessage.
-
linear
Creates the retry schema with a linear delay increment. It returnsfirstDelayfor the first call and then it increments it's value for every call bydelayIncrementuntil reach a limit defined bymaxDelay.- Parameters:
firstDelay- a delay to returns for the first calldelayIncrement- an increment of the returned value.maxDelay- the maximal value to return- Returns:
- computed retry delay with a linear increment
-
constant
Creates the retry schema with a constant result.- Parameters:
delay- a constant delay to return- Returns:
- a
delayvalue
-
geometric
Creates the retry schema as a bounded geometric series.- Parameters:
firstDelay- a delay to returns for the first callratio- a geometric series ratiomaxDelay- the maximal value to return- Returns:
- computed retry delay
-