Jersey-2.33反应式 JAX-RS客户端 API 中的默认最大池大小?

问题描述

下面是我要测试的示例代码

Jersey-2.33 (Reactive JAX-RS) 客户端的认 maxPoolSize 是多少?如何修改

Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target(REST_URI);


    @GET
    @Path("/reactive")
    public void reactive( @Suspended final AsyncResponse asyncResponse) {
        
        CompletionStage<String> response = webTarget
                .request()
                .rx()
                .get(String.class);
        response.thenApply(res -> asyncResponse.resume(res)).exceptionally(e -> asyncResponse.resume(
                Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build()));


    }

认的 ConnectionProvider 是 HttpUrlConnectorProvider,但我无法弄清楚认的 maxPoolSize 或如何更新它。

我还尝试将 ConnectionProvider 更改为下面给出的 ApacheConnectorProvider。

ClientConfig clientConfig = new ClientConfig();
       
        PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
        connectionManager.setMaxTotal(100);
        connectionManager.setDefaultMaxPerRoute(100);

        clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER,connectionManager);

        ApacheConnectorProvider connector = new ApacheConnectorProvider();
        clientConfig.connectorProvider(connector);

        client = ClientBuilder.newClient(clientConfig);

但我一直收到 IllegalStateException 错误

"javax.ws.rs.ProcessingException: java.lang.IllegalStateException: Connection pool shut down"

我假设调用是非阻塞的( .rx() ),ApacheConnectorProvider 在获得响应之前关闭连接。

 CompletionStage<String> response = webTarget
                .request()
                .rx()
                .get(String.class);

在 VertX 中,MaxPoolSize 可以通过提供 WebClientOptions 来设置

WebClientOptions webClientOptions = new WebClientOptions().setMaxPoolSize(maxPoolSize);
        this.client = WebClient.create(vertx,webClientOptions);

有没有办法为 Reactive Jersey (JAX-RS) 客户端配置连接池?

我也试过Jax rs client pool
How does http connection pooling work in work in Jersey?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)