Spring Boot java.util.concurrent.ThreadPoolExecutor大小

Spring Boot java.util.concurrent.ThreadPoolExecutor大小,java,spring,multithreading,Java,Spring,Multithreading,目前,我正在测试我的SpringBoot应用程序,它是一个带有断路器模式的rest服务。现在 我同时使用20个线程调用了我的服务,并获得以下日志条目: Task java.util.concurrent.FutureTask@127adac1[Not completed, task = java.util.concurrent.Executors$RunnableAdapter@74bf28cd[Wrapped task = null]] rejected from java.util.conc

目前,我正在测试我的SpringBoot应用程序,它是一个带有断路器模式的rest服务。现在 我同时使用20个线程调用了我的服务,并获得以下日志条目:

Task java.util.concurrent.FutureTask@127adac1[Not completed, task = java.util.concurrent.Executors$RunnableAdapter@74bf28cd[Wrapped task = null]] rejected from java.util.concurrent.ThreadPoolExecutor@19ae13b2[Running, pool size = 10, active threads = 10, queued tasks = 0, completed tasks = 16]
所以我的问题是线程池的最大大小是realy 10,我能将它设置为不同的大小吗

我找到了属性server.tomcat.max threads,并将其设置为10,所有请求都将通过

编辑

我正在使用Spring Boot Resttemplate调用另一个rest服务,这会导致问题吗

    @HystrixCommand(
        commandKey = "callRestService", fallbackMethod = "failCallRestService", ignoreExceptions = DataNotFoundException.class)
    public ResponseEntity<DataAtomsResponse> callRestService(String searchItem, String trackingId)
        throws RestServiceNotAvailableException
    {
        ThreadContext.put("trackingID", trackingId);
        configureRestTemplate();
        LOGGER.info("Received request with trackingId: {}", trackingId);
        Map<String, String> restUrlParams = new HashMap<>();
        restUrlParams.put(REST_URL_PARAMETER, searchItem);
        HttpEntity<String> entity = getRestParameters(trackingId);

        DataAtomsResponse dataAtomsResponse;
        LOGGER.info("Request RestService trackingID: {}", trackingId);
        ResponseEntity<String> dataResponse=
            restTemplate.exchange(config.getRestServiceUrl(), HttpMethod.GET, entity, String.class, restUrlParams);

        if (dataResponse.getStatusCode() == HttpStatus.OK || dataResponse.getStatusCode() == HttpStatus.NOT_FOUND) {
            LOGGER.debug("Transform result from RestService to JSON trackingID: {}", trackingId);
            dataAtomsResponse = dataParser.parse(dataResponse.getBody(), searchItem, trackingId);
            return ResponseEntity.ok(dataAtomsResponse );
        }
        else {
            throw new RestServiceNotAvailableException(dataResponse.getStatusCode().getReasonPhrase());
        }
    }
@HystrixCommand(
commandKey=“callRestService”,fallbackMethod=“failCallRestService”,ignoreExceptions=DataNotFoundException.class)
public ResponseEntity callRestService(字符串搜索项,字符串跟踪ID)
引发RestServiceNotAvailableException
{
ThreadContext.put(“trackingID”,trackingID);
configureRestTemplate();
info(“接收到的trackingId为{}”、trackingId的请求);
Map restUrlParams=newhashmap();
put(REST\u URL\u参数,searchItem);
HttpEntity=getRestParameters(trackingId);
DataAtomsResponse DataAtomsResponse;
info(“请求RestService trackingID:{}”,trackingID);
响应性数据响应=
restemplate.exchange(config.getRestServiceUrl(),HttpMethod.GET,entity,String.class,restUrlParams);
如果(dataResponse.getStatusCode()==HttpStatus.OK | | dataResponse.getStatusCode()==HttpStatus.NOT|u FOUND){
debug(“将结果从RestService转换为JSON trackingID:{}”,trackingID);
dataAtomsResponse=dataParser.parse(dataResponse.getBody(),searchItem,trackingId);
返回ResponseEntity.ok(dataAtomsResponse);
}
否则{
抛出新的RestServiceNotAvailableException(dataResponse.getStatusCode().getReasonPhrase());
}
}

我没有在任何其他类中实现任何ThreadPoolExecuter。

我发现了问题所在。 Histrix使用普通java ThreadPoolExecutor,最大线程数的值设置为10。这篇文章对我帮助很大。所以我设置了这些配置

hystrix.threadpool.default.maximumSize=32
hystrix.threadpool.default.allowMaximumSizeToDivergeFromCoreSize=true
server.tomcat.max-threads=32```

很难知道你到底有什么问题。我建议您发布设置ThreadPoolExecutor的代码以及如何使用它。ThreadPoolExecutor上的JavaAPI非常好。确保您了解如何使用它,因为这个类是高度可定制的。例如,“我用20个线程调用它…”不确定“它”是什么,但如果“它”是一个
执行器服务
,那么您就不能用线程调用它。您提交给executor服务的对象是任务,executor服务使用其自己的工作线程来执行/执行您的任务。首先感谢您的帮助。ChaudPain我想我没有实现任何线程池执行器,但让我检查一下。Solomon这意味着我在中的服务,我正在用jmeter测试它。