Class Resilience4jConfigurationProperties
- java.lang.Object
-
- org.apache.camel.main.Resilience4jConfigurationProperties
-
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.camel.spi.BootstrapCloseable
@Configurer(bootstrap=true, extended=true) public class Resilience4jConfigurationProperties extends Object implements org.apache.camel.spi.BootstrapCloseableGlobal configuration for Resilience EIP circuit breaker.
-
-
Constructor Summary
Constructors Constructor Description Resilience4jConfigurationProperties(MainConfigurationProperties parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()MainConfigurationPropertiesend()BooleangetAutomaticTransitionFromOpenToHalfOpenEnabled()BooleangetBulkheadEnabled()IntegergetBulkheadMaxConcurrentCalls()IntegergetBulkheadMaxWaitDuration()StringgetCircuitBreaker()StringgetConfig()FloatgetFailureRateThreshold()IntegergetMinimumNumberOfCalls()IntegergetPermittedNumberOfCallsInHalfOpenState()IntegergetSlidingWindowSize()StringgetSlidingWindowType()IntegergetSlowCallDurationThreshold()FloatgetSlowCallRateThreshold()BooleangetThrowExceptionWhenHalfOpenOrOpenState()BooleangetTimeoutCancelRunningFuture()IntegergetTimeoutDuration()BooleangetTimeoutEnabled()StringgetTimeoutExecutorService()IntegergetWaitDurationInOpenState()BooleangetWritableStackTraceEnabled()voidsetAutomaticTransitionFromOpenToHalfOpenEnabled(Boolean automaticTransitionFromOpenToHalfOpenEnabled)Enables automatic transition from OPEN to HALF_OPEN state once the waitDurationInOpenState has passed.voidsetBulkheadEnabled(Boolean bulkheadEnabled)Whether bulkhead is enabled or not on the circuit breaker.voidsetBulkheadMaxConcurrentCalls(Integer bulkheadMaxConcurrentCalls)Configures the max amount of concurrent calls the bulkhead will support.voidsetBulkheadMaxWaitDuration(Integer bulkheadMaxWaitDuration)Configures a maximum amount of time which the calling thread will wait to enter the bulkhead.voidsetCircuitBreaker(String circuitBreaker)Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreaker instance to lookup and use from the registry.voidsetConfig(String config)Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreakerConfig instance to lookup and use from the registry.voidsetFailureRateThreshold(Float failureRateThreshold)Configures the failure rate threshold in percentage.voidsetMinimumNumberOfCalls(Integer minimumNumberOfCalls)Configures configures the minimum number of calls which are required (per sliding window period) before the CircuitBreaker can calculate the error rate.voidsetPermittedNumberOfCallsInHalfOpenState(Integer permittedNumberOfCallsInHalfOpenState)Configures the number of permitted calls when the CircuitBreaker is half open.voidsetSlidingWindowSize(Integer slidingWindowSize)Configures the size of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed.voidsetSlidingWindowType(String slidingWindowType)Configures the type of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed.voidsetSlowCallDurationThreshold(Integer slowCallDurationThreshold)Configures the duration threshold (seconds) above which calls are considered as slow and increase the slow calls percentage.voidsetSlowCallRateThreshold(Float slowCallRateThreshold)Configures a threshold in percentage.voidsetThrowExceptionWhenHalfOpenOrOpenState(Boolean throwExceptionWhenHalfOpenOrOpenState)Whether to throw io.github.resilience4j.circuitbreaker.CallNotPermittedException when the call is rejected due circuit breaker is half open or open.voidsetTimeoutCancelRunningFuture(Boolean timeoutCancelRunningFuture)Configures whether cancel is called on the running future.voidsetTimeoutDuration(Integer timeoutDuration)Configures the thread execution timeout (millis).voidsetTimeoutEnabled(Boolean timeoutEnabled)Whether timeout is enabled or not on the circuit breaker.voidsetTimeoutExecutorService(String timeoutExecutorService)References to a custom thread pool to use when timeout is enabled (usesForkJoinPool.commonPool()by default)voidsetWaitDurationInOpenState(Integer waitDurationInOpenState)Configures the wait duration (in seconds) which specifies how long the CircuitBreaker should stay open, before it switches to half open.voidsetWritableStackTraceEnabled(Boolean writableStackTraceEnabled)Enables writable stack traces.Resilience4jConfigurationPropertieswithAutomaticTransitionFromOpenToHalfOpenEnabled(Boolean automaticTransitionFromOpenToHalfOpenEnabled)Resilience4jConfigurationPropertieswithBulkheadEnabled(Boolean bulkheadEnabled)Whether bulkhead is enabled or not on the circuit breaker.Resilience4jConfigurationPropertieswithBulkheadMaxConcurrentCalls(Integer bulkheadMaxConcurrentCalls)Configures the max amount of concurrent calls the bulkhead will support.Resilience4jConfigurationPropertieswithBulkheadMaxWaitDuration(Integer bulkheadMaxWaitDuration)Configures a maximum amount of time which the calling thread will wait to enter the bulkhead.Resilience4jConfigurationPropertieswithCircuitBreakerRef(String circuitBreakerRef)Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreaker instance to lookup and use from the registry.Resilience4jConfigurationPropertieswithConfigRef(String configRef)Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreakerConfig instance to lookup and use from the registry.Resilience4jConfigurationPropertieswithFailureRateThreshold(Float failureRateThreshold)Configures the failure rate threshold in percentage.Resilience4jConfigurationPropertieswithMinimumNumberOfCalls(Integer minimumNumberOfCalls)Configures configures the minimum number of calls which are required (per sliding window period) before the CircuitBreaker can calculate the error rate.Resilience4jConfigurationPropertieswithPermittedNumberOfCallsInHalfOpenState(Integer permittedNumberOfCallsInHalfOpenState)Configures the number of permitted calls when the CircuitBreaker is half open.Resilience4jConfigurationPropertieswithSlidingWindowSize(Integer slidingWindowSize)Configures the size of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed.Resilience4jConfigurationPropertieswithSlidingWindowType(String slidingWindowType)Configures the type of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed.Resilience4jConfigurationPropertieswithSlowCallDurationThreshold(Integer slowCallDurationThreshold)Configures the duration threshold (seconds) above which calls are considered as slow and increase the slow calls percentage.Resilience4jConfigurationPropertieswithSlowCallRateThreshold(Float slowCallRateThreshold)Configures a threshold in percentage.Resilience4jConfigurationPropertieswithThrowExceptionWhenHalfOpenOrOpenState(Boolean throwExceptionWhenHalfOpenOrOpenState)Whether to throw io.github.resilience4j.circuitbreaker.CallNotPermittedException when the call is rejected due circuit breaker is half open or open.Resilience4jConfigurationPropertieswithTimeoutCancelRunningFuture(Boolean timeoutCancelRunningFuture)Configures whether cancel is called on the running future.Resilience4jConfigurationPropertieswithTimeoutDuration(Integer timeoutDuration)Configures the thread execution timeout (millis).Resilience4jConfigurationPropertieswithTimeoutEnabled(Boolean timeoutEnabled)Whether timeout is enabled or not on the circuit breaker.Resilience4jConfigurationPropertieswithTimeoutExecutorServiceRef(String timeoutExecutorServiceRef)References to a custom thread pool to use when timeout is enabled (usesForkJoinPool.commonPool()by default)Resilience4jConfigurationPropertieswithWaitDurationInOpenState(Integer waitDurationInOpenState)Configures the wait duration (in seconds) which specifies how long the CircuitBreaker should stay open, before it switches to half open.Resilience4jConfigurationPropertieswithWritableStackTraceEnabled(Boolean writableStackTraceEnabled)Enables writable stack traces.
-
-
-
Constructor Detail
-
Resilience4jConfigurationProperties
public Resilience4jConfigurationProperties(MainConfigurationProperties parent)
-
-
Method Detail
-
end
public MainConfigurationProperties end()
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getCircuitBreaker
public String getCircuitBreaker()
-
setCircuitBreaker
public void setCircuitBreaker(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.
-
getConfig
public String getConfig()
-
setConfig
public void setConfig(String config)
Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreakerConfig instance to lookup and use from the registry.
-
getFailureRateThreshold
public Float getFailureRateThreshold()
-
setFailureRateThreshold
public void setFailureRateThreshold(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.
-
getPermittedNumberOfCallsInHalfOpenState
public Integer getPermittedNumberOfCallsInHalfOpenState()
-
setPermittedNumberOfCallsInHalfOpenState
public void setPermittedNumberOfCallsInHalfOpenState(Integer permittedNumberOfCallsInHalfOpenState)
Configures the number of permitted calls when the CircuitBreaker is half open.The size must be greater than 0. Default size is 10.
-
getThrowExceptionWhenHalfOpenOrOpenState
public Boolean getThrowExceptionWhenHalfOpenOrOpenState()
-
setThrowExceptionWhenHalfOpenOrOpenState
public void setThrowExceptionWhenHalfOpenOrOpenState(Boolean throwExceptionWhenHalfOpenOrOpenState)
Whether to throw io.github.resilience4j.circuitbreaker.CallNotPermittedException when the call is rejected due circuit breaker is half open or open.
-
getSlidingWindowSize
public Integer getSlidingWindowSize()
-
setSlidingWindowSize
public void setSlidingWindowSize(Integer slidingWindowSize)
Configures the size of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed.slidingWindowSizeconfigures the size of the sliding window. Sliding window can either be count-based or time-based. IfslidingWindowTypeis COUNT_BASED, the lastslidingWindowSizecalls are recorded and aggregated. IfslidingWindowTypeis TIME_BASED, the calls of the lastslidingWindowSizeseconds are recorded and aggregated.The
slidingWindowSizemust be greater than 0. TheminimumNumberOfCallsmust be greater than 0. If the slidingWindowType is COUNT_BASED, theminimumNumberOfCallscannot be greater thanslidingWindowSize. If the slidingWindowType is TIME_BASED, you can pick whatever you want. Default slidingWindowSize is 100.
-
getSlidingWindowType
public String getSlidingWindowType()
-
setSlidingWindowType
public void setSlidingWindowType(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. IfslidingWindowTypeis COUNT_BASED, the lastslidingWindowSizecalls are recorded and aggregated. IfslidingWindowTypeis TIME_BASED, the calls of the lastslidingWindowSizeseconds are recorded and aggregated. Default slidingWindowType is COUNT_BASED.
-
getMinimumNumberOfCalls
public Integer getMinimumNumberOfCalls()
-
setMinimumNumberOfCalls
public void setMinimumNumberOfCalls(Integer 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, ifminimumNumberOfCallsis 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
-
getWritableStackTraceEnabled
public Boolean getWritableStackTraceEnabled()
-
setWritableStackTraceEnabled
public void setWritableStackTraceEnabled(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).
-
getWaitDurationInOpenState
public Integer getWaitDurationInOpenState()
-
setWaitDurationInOpenState
public void setWaitDurationInOpenState(Integer 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.
-
getAutomaticTransitionFromOpenToHalfOpenEnabled
public Boolean getAutomaticTransitionFromOpenToHalfOpenEnabled()
-
setAutomaticTransitionFromOpenToHalfOpenEnabled
public void setAutomaticTransitionFromOpenToHalfOpenEnabled(Boolean automaticTransitionFromOpenToHalfOpenEnabled)
Enables automatic transition from OPEN to HALF_OPEN state once the waitDurationInOpenState has passed.
-
getSlowCallRateThreshold
public Float getSlowCallRateThreshold()
-
setSlowCallRateThreshold
public void setSlowCallRateThreshold(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.
-
getSlowCallDurationThreshold
public Integer getSlowCallDurationThreshold()
-
setSlowCallDurationThreshold
public void setSlowCallDurationThreshold(Integer slowCallDurationThreshold)
Configures the duration threshold (seconds) above which calls are considered as slow and increase the slow calls percentage. Default value is 60 seconds.
-
getBulkheadEnabled
public Boolean getBulkheadEnabled()
-
setBulkheadEnabled
public void setBulkheadEnabled(Boolean bulkheadEnabled)
Whether bulkhead is enabled or not on the circuit breaker.
-
getBulkheadMaxConcurrentCalls
public Integer getBulkheadMaxConcurrentCalls()
-
setBulkheadMaxConcurrentCalls
public void setBulkheadMaxConcurrentCalls(Integer bulkheadMaxConcurrentCalls)
Configures the max amount of concurrent calls the bulkhead will support.
-
getBulkheadMaxWaitDuration
public Integer getBulkheadMaxWaitDuration()
-
setBulkheadMaxWaitDuration
public void setBulkheadMaxWaitDuration(Integer 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.
-
getTimeoutEnabled
public Boolean getTimeoutEnabled()
-
setTimeoutEnabled
public void setTimeoutEnabled(Boolean timeoutEnabled)
Whether timeout is enabled or not on the circuit breaker. Default is false.
-
getTimeoutExecutorService
public String getTimeoutExecutorService()
-
setTimeoutExecutorService
public void setTimeoutExecutorService(String timeoutExecutorService)
References to a custom thread pool to use when timeout is enabled (usesForkJoinPool.commonPool()by default)
-
getTimeoutDuration
public Integer getTimeoutDuration()
-
setTimeoutDuration
public void setTimeoutDuration(Integer timeoutDuration)
Configures the thread execution timeout (millis). Default value is 1000 millis (1 second).
-
getTimeoutCancelRunningFuture
public Boolean getTimeoutCancelRunningFuture()
-
setTimeoutCancelRunningFuture
public void setTimeoutCancelRunningFuture(Boolean timeoutCancelRunningFuture)
Configures whether cancel is called on the running future. Defaults to true.
-
withCircuitBreakerRef
public Resilience4jConfigurationProperties withCircuitBreakerRef(String circuitBreakerRef)
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.
-
withConfigRef
public Resilience4jConfigurationProperties withConfigRef(String configRef)
Refers to an existing io.github.resilience4j.circuitbreaker.CircuitBreakerConfig instance to lookup and use from the registry.
-
withFailureRateThreshold
public Resilience4jConfigurationProperties withFailureRateThreshold(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.
-
withPermittedNumberOfCallsInHalfOpenState
public Resilience4jConfigurationProperties withPermittedNumberOfCallsInHalfOpenState(Integer permittedNumberOfCallsInHalfOpenState)
Configures the number of permitted calls when the CircuitBreaker is half open.The size must be greater than 0. Default size is 10.
-
withThrowExceptionWhenHalfOpenOrOpenState
public Resilience4jConfigurationProperties withThrowExceptionWhenHalfOpenOrOpenState(Boolean throwExceptionWhenHalfOpenOrOpenState)
Whether to throw io.github.resilience4j.circuitbreaker.CallNotPermittedException when the call is rejected due circuit breaker is half open or open.
-
withSlidingWindowSize
public Resilience4jConfigurationProperties withSlidingWindowSize(Integer slidingWindowSize)
Configures the size of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed.slidingWindowSizeconfigures the size of the sliding window. Sliding window can either be count-based or time-based. IfslidingWindowTypeis COUNT_BASED, the lastslidingWindowSizecalls are recorded and aggregated. IfslidingWindowTypeis TIME_BASED, the calls of the lastslidingWindowSizeseconds are recorded and aggregated.The
slidingWindowSizemust be greater than 0. TheminimumNumberOfCallsmust be greater than 0. If the slidingWindowType is COUNT_BASED, theminimumNumberOfCallscannot be greater thanslidingWindowSize. If the slidingWindowType is TIME_BASED, you can pick whatever you want. Default slidingWindowSize is 100.
-
withSlidingWindowType
public Resilience4jConfigurationProperties withSlidingWindowType(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. IfslidingWindowTypeis COUNT_BASED, the lastslidingWindowSizecalls are recorded and aggregated. IfslidingWindowTypeis TIME_BASED, the calls of the lastslidingWindowSizeseconds are recorded and aggregated. Default slidingWindowType is COUNT_BASED.
-
withMinimumNumberOfCalls
public Resilience4jConfigurationProperties withMinimumNumberOfCalls(Integer 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, ifminimumNumberOfCallsis 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
-
withWritableStackTraceEnabled
public Resilience4jConfigurationProperties withWritableStackTraceEnabled(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).
-
withWaitDurationInOpenState
public Resilience4jConfigurationProperties withWaitDurationInOpenState(Integer 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.
-
withAutomaticTransitionFromOpenToHalfOpenEnabled
public Resilience4jConfigurationProperties withAutomaticTransitionFromOpenToHalfOpenEnabled(Boolean automaticTransitionFromOpenToHalfOpenEnabled)
-
withSlowCallRateThreshold
public Resilience4jConfigurationProperties withSlowCallRateThreshold(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.
-
withSlowCallDurationThreshold
public Resilience4jConfigurationProperties withSlowCallDurationThreshold(Integer slowCallDurationThreshold)
Configures the duration threshold (seconds) above which calls are considered as slow and increase the slow calls percentage. Default value is 60 seconds.
-
withBulkheadEnabled
public Resilience4jConfigurationProperties withBulkheadEnabled(Boolean bulkheadEnabled)
Whether bulkhead is enabled or not on the circuit breaker.
-
withBulkheadMaxConcurrentCalls
public Resilience4jConfigurationProperties withBulkheadMaxConcurrentCalls(Integer bulkheadMaxConcurrentCalls)
Configures the max amount of concurrent calls the bulkhead will support.
-
withBulkheadMaxWaitDuration
public Resilience4jConfigurationProperties withBulkheadMaxWaitDuration(Integer 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.
-
withTimeoutEnabled
public Resilience4jConfigurationProperties withTimeoutEnabled(Boolean timeoutEnabled)
Whether timeout is enabled or not on the circuit breaker. Default is false.
-
withTimeoutExecutorServiceRef
public Resilience4jConfigurationProperties withTimeoutExecutorServiceRef(String timeoutExecutorServiceRef)
References to a custom thread pool to use when timeout is enabled (usesForkJoinPool.commonPool()by default)
-
withTimeoutDuration
public Resilience4jConfigurationProperties withTimeoutDuration(Integer timeoutDuration)
Configures the thread execution timeout (millis). Default value is 1000 millis (1 second).
-
withTimeoutCancelRunningFuture
public Resilience4jConfigurationProperties withTimeoutCancelRunningFuture(Boolean timeoutCancelRunningFuture)
Configures whether cancel is called on the running future. Defaults to true.
-
-