Class Resilience4jConfigurationDefinition
- java.lang.Object
-
- org.apache.camel.model.IdentifiedType
-
- org.apache.camel.model.Resilience4jConfigurationCommon
-
- org.apache.camel.model.Resilience4jConfigurationDefinition
-
@Metadata(label="configuration,eip") @Configurer(extended=true) public class Resilience4jConfigurationDefinition extends Resilience4jConfigurationCommon
Resilience4j Circuit Breaker EIP configuration
-
-
Constructor Summary
Constructors Constructor Description Resilience4jConfigurationDefinition()
Resilience4jConfigurationDefinition(CircuitBreakerDefinition parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resilience4jConfigurationDefinition
automaticTransitionFromOpenToHalfOpenEnabled(boolean automaticTransitionFromOpenToHalfOpenEnabled)
Enables automatic transition from OPEN to HALF_OPEN state once the waitDurationInOpenState has passed.Resilience4jConfigurationDefinition
bulkheadEnabled(boolean bulkheadEnabled)
Whether bulkhead is enabled or not on the circuit breaker.Resilience4jConfigurationDefinition
bulkheadMaxConcurrentCalls(int bulkheadMaxConcurrentCalls)
Configures the max amount of concurrent calls the bulkhead will support.Resilience4jConfigurationDefinition
bulkheadMaxWaitDuration(int bulkheadMaxWaitDuration)
Configures a maximum amount of time which the calling thread will wait to enter the bulkhead.Resilience4jConfigurationDefinition
circuitBreaker(String circuitBreaker)
Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreaker instance to lookup and use from the registry.Resilience4jConfigurationDefinition
config(String ref)
Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreakerConfig instance to lookup and use from the registry.CircuitBreakerDefinition
end()
End of configuration.Resilience4jConfigurationDefinition
failureRateThreshold(float failureRateThreshold)
Configures the failure rate threshold in percentage.Resilience4jConfigurationDefinition
minimumNumberOfCalls(int minimumNumberOfCalls)
Configures configures the minimum number of calls which are required (per sliding window period) before the CircuitBreaker can calculate the error rate.Resilience4jConfigurationDefinition
permittedNumberOfCallsInHalfOpenState(int permittedNumberOfCallsInHalfOpenState)
Configures the number of permitted calls when the CircuitBreaker is half open.Resilience4jConfigurationDefinition
slidingWindowSize(int slidingWindowSize)
Configures the size of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed.Resilience4jConfigurationDefinition
slidingWindowType(String slidingWindowType)
Configures the type of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed.Resilience4jConfigurationDefinition
slowCallDurationThreshold(int slowCallDurationThreshold)
Configures the duration threshold (seconds) above which calls are considered as slow and increase the slow calls percentage.Resilience4jConfigurationDefinition
slowCallRateThreshold(float slowCallRateThreshold)
Configures a threshold in percentage.Resilience4jConfigurationDefinition
throwExceptionWhenHalfOpenOrOpenState(boolean throwExceptionWhenHalfOpenOrOpenState)
Whether to throw io.github.resilience4j.circuitbreaker.CallNotPermittedException when the call is rejected due circuit breaker is half open or open.Resilience4jConfigurationDefinition
timeoutCancelRunningFuture(boolean timeoutCancelRunningFuture)
Configures whether cancel is called on the running future.Resilience4jConfigurationDefinition
timeoutDuration(int timeoutDuration)
Configures the thread execution timeout (millis).Resilience4jConfigurationDefinition
timeoutEnabled(boolean timeoutEnabled)
Whether timeout is enabled or not on the circuit breaker.Resilience4jConfigurationDefinition
timeoutExecutorService(String executorService)
References to a custom thread pool to use when timeout is enabled (usesForkJoinPool.commonPool()
by default)Resilience4jConfigurationDefinition
waitDurationInOpenState(int waitDurationInOpenState)
Configures the wait duration (in seconds) which specifies how long the CircuitBreaker should stay open, before it switches to half open.Resilience4jConfigurationDefinition
writableStackTraceEnabled(boolean writableStackTraceEnabled)
Enables writable stack traces.-
Methods inherited from class org.apache.camel.model.Resilience4jConfigurationCommon
getAutomaticTransitionFromOpenToHalfOpenEnabled, getBulkheadEnabled, getBulkheadMaxConcurrentCalls, getBulkheadMaxWaitDuration, getCircuitBreaker, getConfig, getFailureRateThreshold, getMinimumNumberOfCalls, getPermittedNumberOfCallsInHalfOpenState, getSlidingWindowSize, getSlidingWindowType, getSlowCallDurationThreshold, getSlowCallRateThreshold, getThrowExceptionWhenHalfOpenOrOpenState, getTimeoutCancelRunningFuture, getTimeoutDuration, getTimeoutEnabled, getTimeoutExecutorService, getWaitDurationInOpenState, getWritableStackTraceEnabled, setAutomaticTransitionFromOpenToHalfOpenEnabled, setBulkheadEnabled, setBulkheadMaxConcurrentCalls, setBulkheadMaxWaitDuration, setCircuitBreaker, setConfig, setFailureRateThreshold, setMinimumNumberOfCalls, setPermittedNumberOfCallsInHalfOpenState, setSlidingWindowSize, setSlidingWindowType, setSlowCallDurationThreshold, setSlowCallRateThreshold, setThrowExceptionWhenHalfOpenOrOpenState, setTimeoutCancelRunningFuture, setTimeoutDuration, setTimeoutEnabled, setTimeoutExecutorService, setWaitDurationInOpenState, setWritableStackTraceEnabled
-
Methods inherited from class org.apache.camel.model.IdentifiedType
getId, setId
-
-
-
-
Constructor Detail
-
Resilience4jConfigurationDefinition
public Resilience4jConfigurationDefinition()
-
Resilience4jConfigurationDefinition
public Resilience4jConfigurationDefinition(CircuitBreakerDefinition parent)
-
-
Method Detail
-
circuitBreaker
public Resilience4jConfigurationDefinition circuitBreaker(String circuitBreaker)
Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreaker instance to lookup and use from the registry. When using this, then any other circuit breaker options are not in use.
-
config
public Resilience4jConfigurationDefinition config(String ref)
Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreakerConfig instance to lookup and use from the registry.
-
failureRateThreshold
public Resilience4jConfigurationDefinition failureRateThreshold(float failureRateThreshold)
Configures the failure rate threshold in percentage. If the failure rate is equal or greater than the threshold the CircuitBreaker transitions to open and starts short-circuiting calls.The threshold must be greater than 0 and not greater than 100. Default value is 50 percentage.
-
permittedNumberOfCallsInHalfOpenState
public Resilience4jConfigurationDefinition permittedNumberOfCallsInHalfOpenState(int permittedNumberOfCallsInHalfOpenState)
Configures the number of permitted calls when the CircuitBreaker is half open.The size must be greater than 0. Default size is 10.
-
throwExceptionWhenHalfOpenOrOpenState
public Resilience4jConfigurationDefinition throwExceptionWhenHalfOpenOrOpenState(boolean throwExceptionWhenHalfOpenOrOpenState)
Whether to throw io.github.resilience4j.circuitbreaker.CallNotPermittedException when the call is rejected due circuit breaker is half open or open.
-
slidingWindowSize
public Resilience4jConfigurationDefinition slidingWindowSize(int slidingWindowSize)
Configures the size of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed.slidingWindowSize
configures the size of the sliding window. Sliding window can either be count-based or time-based. IfslidingWindowType
is COUNT_BASED, the lastslidingWindowSize
calls are recorded and aggregated. IfslidingWindowType
is TIME_BASED, the calls of the lastslidingWindowSize
seconds are recorded and aggregated.The
slidingWindowSize
must be greater than 0. TheminimumNumberOfCalls
must be greater than 0. If the slidingWindowType is COUNT_BASED, theminimumNumberOfCalls
cannot be greater thanslidingWindowSize
. If the slidingWindowType is TIME_BASED, you can pick whatever you want. Default slidingWindowSize is 100.
-
slidingWindowType
public Resilience4jConfigurationDefinition slidingWindowType(String slidingWindowType)
Configures the type of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed. Sliding window can either be count-based or time-based. IfslidingWindowType
is COUNT_BASED, the lastslidingWindowSize
calls are recorded and aggregated. IfslidingWindowType
is TIME_BASED, the calls of the lastslidingWindowSize
seconds are recorded and aggregated. Default slidingWindowType is COUNT_BASED.
-
minimumNumberOfCalls
public Resilience4jConfigurationDefinition minimumNumberOfCalls(int minimumNumberOfCalls)
Configures configures the minimum number of calls which are required (per sliding window period) before the CircuitBreaker can calculate the error rate. For example, ifminimumNumberOfCalls
is 10, then at least 10 calls must be recorded, before the failure rate can be calculated. If only 9 calls have been recorded the CircuitBreaker will not transition to open even if all 9 calls have failed. Default minimumNumberOfCalls is 100
-
writableStackTraceEnabled
public Resilience4jConfigurationDefinition writableStackTraceEnabled(boolean writableStackTraceEnabled)
Enables writable stack traces. When set to false, Exception.getStackTrace returns a zero length array. This may be used to reduce log spam when the circuit breaker is open as the cause of the exceptions is already known (the circuit breaker is short-circuiting calls).
-
waitDurationInOpenState
public Resilience4jConfigurationDefinition waitDurationInOpenState(int waitDurationInOpenState)
Configures the wait duration (in seconds) which specifies how long the CircuitBreaker should stay open, before it switches to half open. Default value is 60 seconds.
-
automaticTransitionFromOpenToHalfOpenEnabled
public Resilience4jConfigurationDefinition automaticTransitionFromOpenToHalfOpenEnabled(boolean automaticTransitionFromOpenToHalfOpenEnabled)
Enables automatic transition from OPEN to HALF_OPEN state once the waitDurationInOpenState has passed.
-
slowCallRateThreshold
public Resilience4jConfigurationDefinition slowCallRateThreshold(float slowCallRateThreshold)
Configures a threshold in percentage. The CircuitBreaker considers a call as slow when the call duration is greater than slowCallDurationThreshold(Duration. When the percentage of slow calls is equal or greater the threshold, the CircuitBreaker transitions to open and starts short-circuiting calls.The threshold must be greater than 0 and not greater than 100. Default value is 100 percentage which means that all recorded calls must be slower than slowCallDurationThreshold.
-
slowCallDurationThreshold
public Resilience4jConfigurationDefinition slowCallDurationThreshold(int slowCallDurationThreshold)
Configures the duration threshold (seconds) above which calls are considered as slow and increase the slow calls percentage. Default value is 60 seconds.
-
bulkheadEnabled
public Resilience4jConfigurationDefinition bulkheadEnabled(boolean bulkheadEnabled)
Whether bulkhead is enabled or not on the circuit breaker. Default is false.
-
bulkheadMaxConcurrentCalls
public Resilience4jConfigurationDefinition bulkheadMaxConcurrentCalls(int bulkheadMaxConcurrentCalls)
Configures the max amount of concurrent calls the bulkhead will support.
-
bulkheadMaxWaitDuration
public Resilience4jConfigurationDefinition bulkheadMaxWaitDuration(int bulkheadMaxWaitDuration)
Configures a maximum amount of time which the calling thread will wait to enter the bulkhead. If bulkhead has space available, entry is guaranteed and immediate. If bulkhead is full, calling threads will contest for space, if it becomes available. maxWaitDuration can be set to 0.Note: for threads running on an event-loop or equivalent (rx computation pool, etc), setting maxWaitDuration to 0 is highly recommended. Blocking an event-loop thread will most likely have a negative effect on application throughput.
-
timeoutEnabled
public Resilience4jConfigurationDefinition timeoutEnabled(boolean timeoutEnabled)
Whether timeout is enabled or not on the circuit breaker. Default is false.
-
timeoutExecutorService
public Resilience4jConfigurationDefinition timeoutExecutorService(String executorService)
References to a custom thread pool to use when timeout is enabled (usesForkJoinPool.commonPool()
by default)
-
timeoutDuration
public Resilience4jConfigurationDefinition timeoutDuration(int timeoutDuration)
Configures the thread execution timeout (millis). Default value is 1000 millis (1 second).
-
timeoutCancelRunningFuture
public Resilience4jConfigurationDefinition timeoutCancelRunningFuture(boolean timeoutCancelRunningFuture)
Configures whether cancel is called on the running future. Defaults to true.
-
end
public CircuitBreakerDefinition end()
End of configuration.
-
-