https://github.com/Netflix/Hystrix/wiki/Configuration#ThreadPool
1.异常
java.util.concurrent.RejectedExecutionException: Rejected command because thread-pool queueSize is at rejection threshold.
at com.netflix.hystrix.strategy.concurrency.HystrixContextScheduler$HystrixContextSchedulerWorker.schedule(HystrixContextScheduler.java:103)
at rx.internal.operators.OperatorSubscribeOn.call(OperatorSubscribeOn.java:45)
at rx.internal.operators.OperatorSubscribeOn.call(OperatorSubscribeOn.java:30)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)
2.使用maxQueueSize需要配合queueSizeRejectionThreshold一起使用
maxQueueSize
This property sets the maximum queue size of the BlockingQueue implementation.
If you set this to -1 then SynchronousQueue will be used, otherwise a positive value will be used with LinkedBlockingQueue.
Note: This property only applies at initialization time since queue implementations cannot be resized or changed without re-initializing the thread executor which is not supported.
If you need to overcome this limitation and to allow dynamic changes in the queue, see the queueSizeRejectionThreshold property.
To change between SynchronousQueue and LinkedBlockingQueue requires a restart.
Default Value −1
Default Property hystrix.threadpool.default.maxQueueSize
Instance Property hystrix.threadpool.HystrixThreadPoolKey.maxQueueSize
How to Set Instance Default
HystrixThreadPoolProperties.Setter()
.withMaxQueueSize(int value)
queueSizeRejectionThreshold
This property sets the queue size rejection threshold — an artificial maximum queue size at which rejections will occur even if maxQueueSize has not been reached. This property exists because the maxQueueSize of a BlockingQueue cannot be dynamically changed and we want to allow you to dynamically change the queue size that affects rejections.
This is used by HystrixCommand when queuing a thread for execution.
Note: This property is not applicable if maxQueueSize == -1.
Default Value 5
Default Property hystrix.threadpool.default.queueSizeRejectionThreshold
Instance Property hystrix.threadpool.HystrixThreadPoolKey.queueSizeRejectionThreshold
How to Set Instance Default
HystrixThreadPoolProperties.Setter()
.withQueueSizeRejectionThreshold(int value)