Feign调用异常[Running, pool size = 10, active threads = 10, queued tasks = 0, completed tasks = n]

Posted 抓手

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Feign调用异常[Running, pool size = 10, active threads = 10, queued tasks = 0, completed tasks = n]相关的知识,希望对你有一定的参考价值。

java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@1e882e6a rejected from java.util.concurrent.ThreadPoolExecutor@28cdff71[Running, pool size = 10, active threads = 10, queued tasks = 0, completed tasks = 25]
	at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2063) ~[na:1.8.0_191]
	at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:830) [na:1.8.0_191]
	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1379) [na:1.8.0_191]
	at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112) ~[na:1.8.0_191]
	at com.netflix.hystrix.strategy.concurrency.HystrixContextScheduler$ThreadPoolWorker.schedule(HystrixContextScheduler.java:172) ~[hystrix-core-1.5.18.jar:1.5.18]
	at com.netflix.hystrix.strategy.concurrency.HystrixContextScheduler$HystrixContextSchedulerWorker.schedule(HystrixContextScheduler.java:106) ~[hystrix-core-1.5.18.jar:1.5.18]
	at rx.internal.operators.OperatorSubscribeOn.call(OperatorSubscribeOn.java:50) ~[rxjava-1.3.8.jar:1.3.8]
	at rx.internal.operators.OperatorSubscribeOn.call(OperatorSubscribeOn.java:30) ~[rxjava-1.3.8.jar:1.3.8]
	at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8]
	at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8]
	at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8]

原因是Feign调用并发量太大,打满了Hystrix的线程池,触发了线程池隔离。

解决办法:

1.对请求限流

2.修改Hystrix的线程池参数:Spring Cloud Hystrix 线程池隔离参数配置_抓手的博客-CSDN博客

更多Hystrix参数配置可参考:hystrix 配置_Lewis·fk的博客-CSDN博客_hystrix配置文件配置

以上是关于Feign调用异常[Running, pool size = 10, active threads = 10, queued tasks = 0, completed tasks = n]的主要内容,如果未能解决你的问题,请参考以下文章

feign服务间调用超时时间

JAVA踩坑记录Feign调用服务时,get请求参数异常

记一次多线程调用Feign接口失败问题

JAVA踩坑记录Feign调用服务时,get请求参数异常

21 服务调用Feign高级

探讨通过Feign配合Hystrix进行调用时异常的处理