Package io.github.resilience4j.bulkhead
Class ThreadPoolBulkheadConfig.Builder
java.lang.Object
io.github.resilience4j.bulkhead.ThreadPoolBulkheadConfig.Builder
- Enclosing class:
- ThreadPoolBulkheadConfig
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a BulkheadConfigcontextPropagator(io.github.resilience4j.core.ContextPropagator... contextPropagators) contextPropagator(Class<? extends io.github.resilience4j.core.ContextPropagator>... contextPropagatorClasses) Configures the context propagator class.coreThreadPoolSize(int coreThreadPoolSize) Configures the core thread pool size.keepAliveDuration(Duration keepAliveDuration) When the number of threads is greater than the core, this is the maximum time duration that excess idle threads will wait for new tasks before terminating.maxThreadPoolSize(int maxThreadPoolSize) Configures the max thread pool size.queueCapacity(int queueCapacity) Configures the capacity of the queue.rejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler) Replaces the defaultThreadPoolExecutor.AbortPolicywith theRejectedExecutionHandlerprovided.writableStackTraceEnabled(boolean writableStackTraceEnabled) Enables writable stack traces.
-
Constructor Details
-
Builder
-
Builder
public Builder()
-
-
Method Details
-
maxThreadPoolSize
Configures the max thread pool size.- Parameters:
maxThreadPoolSize- max thread pool size- Returns:
- the BulkheadConfig.Builder
-
coreThreadPoolSize
Configures the core thread pool size.- Parameters:
coreThreadPoolSize- core thread pool size- Returns:
- the BulkheadConfig.Builder
-
contextPropagator
public final ThreadPoolBulkheadConfig.Builder contextPropagator(@Nullable Class<? extends io.github.resilience4j.core.ContextPropagator>... contextPropagatorClasses) Configures the context propagator class.- Returns:
- the BulkheadConfig.Builder
-
contextPropagator
public final ThreadPoolBulkheadConfig.Builder contextPropagator(io.github.resilience4j.core.ContextPropagator... contextPropagators) -
queueCapacity
Configures the capacity of the queue. UseSynchronousQueuewhenqueueCapacity == 0orArrayBlockingQueuewhenqueueCapacity > 0.- Parameters:
queueCapacity- max concurrent calls- Returns:
- the BulkheadConfig.Builder
-
keepAliveDuration
When the number of threads is greater than the core, this is the maximum time duration that excess idle threads will wait for new tasks before terminating.- Parameters:
keepAliveDuration- maximum wait duration for bulkhead thread pool idle thread- Returns:
- the BulkheadConfig.Builder
-
writableStackTraceEnabled
public ThreadPoolBulkheadConfig.Builder writableStackTraceEnabled(boolean writableStackTraceEnabled) Enables writable stack traces. When set to false,Throwable.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).- Parameters:
writableStackTraceEnabled- flag to control if stack trace is writable- Returns:
- the BulkheadConfig.Builder
-
rejectedExecutionHandler
public ThreadPoolBulkheadConfig.Builder rejectedExecutionHandler(RejectedExecutionHandler rejectedExecutionHandler) Replaces the defaultThreadPoolExecutor.AbortPolicywith theRejectedExecutionHandlerprovided.- Parameters:
rejectedExecutionHandler- handler to use for rejection of execution.- Returns:
- the BulkheadConfig.Builder
-
build
Builds a BulkheadConfig- Returns:
- the BulkheadConfig
-