java.util.concurrent.RejectedExecutionException:拒绝命令,因为线程池队列大小达到拒绝阈值

vin*_*thM 5 spring-boot netflix-eureka netflix-zuul

我们突然开始在应用程序服务中收到以下错误,我们最近没有对配置进行任何更改。任何人都可以提供一些有关错误的信息吗?

Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: xxx service could not be queued for execution and no fallback available.
Caused by: java.util.concurrent.RejectedExecutionException: Rejected command because thread-pool queueSize is at rejection threshold.
Run Code Online (Sandbox Code Playgroud)

网关中的配置为:

hystrix.command.default.execution.isolation.strategy=THREAD
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=360000
hystrix.threadpool.default.coreSize=40
hystrix.command.default.circuitBreaker.forceClosed=true
hystrix.threadpool.default.maxQueueSize=2000
hystrix.threadpool.default.queueSizeRejectionThreshold=1800

zuul.routes.<instance>.path=/<instance>/**
zuul.routes.<instance>.serviceId=<instance>
zuul.routes.<instance>.sensitiveHeaders=
<instance>.ribbon.OkToRetryOnAllOperations=true
<instance>.ribbon.MaxAutoRetriesNextServer=1
<instance>.ribbon.MaxAutoRetries=0
hystrix.command.<instance>.execution.isolation.strategy=THREAD
hystrix.command.<instance>.execution.isolation.thread.timeoutInMilliseconds=360000
hystrix.threadpool.<instance>.coreSize=40
hystrix.command.<instance>.circuitBreaker.forceClosed=true
hystrix.threadpool.<instance>.maximumSize=100
hystrix.threadpool.<instance>.queueSizeRejectionThreshold=80
Run Code Online (Sandbox Code Playgroud)

我们将 coreSize、forceClosed、maxQueueSize 和 quoteSizeRejectionThreshold 作为默认设置,但并未配置此级别。它仍然存在问题。我们尝试重新启动 Gateway 和 Eureka 实例。

小智 0

默认情况下,每个命令都会创建自己的“命名”线程池,每次执行该命令的实例时,都会选择并使用该线程池中的一个线程。尝试使用以下配置。

hystrix.command.<instance>.coreSize=40
hystrix.command.<instance>.circuitBreaker.forceClosed=true
hystrix.command.<instance>.maximumSize=100
hystrix.command.<instance>.queueSizeRejectionThreshold=80
Run Code Online (Sandbox Code Playgroud)

参考