0

Microprofile 允许从 RestClient 定义 connectionPoolSize,如下所示:

io.smallrye.restclient.tests.proxy.HelloClient/property/resteasy.connectionPoolSize = 4

当我在我的项目中设置这个属性时,quarkus 会忽略它。我该如何定义它?

4

2 回答 2

0

如果您配置的客户端是 @RegisterRestClient(configKey="myClient"),则要设置池大小,请使用:

quarkus.rest-client.myClient.connection-pool-size: 5

(...而不是 myClient/mp-rest/connectionPoolSize)

于 2022-02-21T14:01:24.140 回答
0
  1. 创建类MyRestClientBuilderListener实现RestClientBuilderListener

package org.myproject.config

public class MyRestClientBuilderListener implements RestClientBuilderListener {
    
    static final Logger LOG = LoggerFactory.getLogger(MgiRestClientBuilderListener.class);
    static final String CONNECTION_POOL_SIZE_PROP = "config.restclient.connectionPoolSize";

    @Override
    public void onNewBuilder(RestClientBuilder builder) {
        Config cfg = ConfigProvider.getConfig();
        Integer poolSizeConnection = cfg.getValue(CONNECTION_POOL_SIZE_PROP, Integer.class);
        
        if(poolSizeConnection == null) {
            poolSizeConnection = 50;//default
        }

        builder.property("resteasy.connectionPoolSize", poolSizeConnection);
    }
}
  1. META-INF\services中创建名为org.eclipse.microprofile.rest.client.spi.RestClientBuilderListener的文件,其内容为:

org.myproject.config.MyRestClientBuilderListener

于 2021-06-22T13:12:37.693 回答