首页 > 解决方案 > Quarkus Rest Client 永远不会超时

问题描述

其余客户端永远不会超时。多次请求后,quarkus 停止服务新请求。还尝试了 .../mp-rest/connectTimeout=5000 .../mp-rest/readTimeout=5000 但没有运气。

界面看起来像

package org.acme;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

@RegisterRestClient
public interface ExampleClient {

@GET
@Path("/test")
    String test();
}

服务喜欢

package org.acme;

import org.eclipse.microprofile.rest.client.inject.RestClient;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/hello")
public class ExampleResource {

    @Inject
    @RestClient
    ExampleClient exampleClient;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return exampleClient.test();
    }
}

和 application.properties 文件,如

org.acme.ExampleClient/mp-rest/url=http://localhost:8081
org.acme.ExampleClient/mp-rest/connectTimeout=5000
org.acme.ExampleClient/mp-rest/readTimeout=5000

为了测试,调用http://localhost:8080/hello并将 localhost:8081 指向带有断点的调试模式下的服务。

我已经在 quarkus 0.22 和 0.23.2 上进行了测试。

标签: rest-clientquarkus

解决方案


这个问题现在在几天前发布的 0.27 中得到了解决


推荐阅读