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

dnph8jn4  于 2023-10-16  发布在  Spring
关注(0)|答案(1)|浏览(99)

我们突然开始收到以下错误在我们的应用程序服务,我们没有做任何更改配置在最近的时间。谁能提供一些关于错误的信息?

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.

网关中的配置包括:

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

我们将coreSize、forceClosed、maxSideSize和quoteSizeRejectionThreshold作为默认值,而不是将其配置为此级别。它仍然有问题。我们尝试重新启动网关和Eureka 示例。

xtfmy6hx

xtfmy6hx1#

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

hystrix.command.<instance>.coreSize=40
hystrix.command.<instance>.circuitBreaker.forceClosed=true
hystrix.command.<instance>.maximumSize=100
hystrix.command.<instance>.queueSizeRejectionThreshold=80

Reference

相关问题