java - WLP Microprofile 容错舱壁实现未启动

标签 java websphere-liberty fault-tolerance microprofile

尝试在 Java HotSpot(TM) 64 位服务器 VM 版本 1.8.0_161-b12 上测试 WebSphere Liberty (WebSphere Application Server 18.0.0.3/wlp-1.0.22.cl180320180905-2337) 中的 Microprofile 容错能力( en_US),但我无法启动舱壁逻辑。

创建了 REST 资源:

import org.eclipse.microprofile.faulttolerance.Bulkhead;

@Path("bulk")
public class BulkheadResource {

    @GET
    @Bulkhead(1)
    public String getBulk() {
        return getMessage();
    }

    private String getMessage() {
        String vMessage = "Start: " + System.currentTimeMillis();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return vMessage;
    }
}

并使用 3 个线程从 JMeter 调用它。我的期望是第一个调用可以正常工作,但第二个和第三个调用会失败,因为第一个调用占用了唯一的线程,并且舱壁可以工作。

5 秒后,所有三个线程都返回了 200 响应:

timeStamp   elapsed label   responseCode    threadName  grpThreads
1539095137936   5057    GET Bulk    200 Micro Profile 1-1   3
1539095138272   5041    GET Bulk    200 Micro Profile 1-2   2
1539095138608   5029    GET Bulk    200 Micro Profile 1-3   1

服务器.xml:

<featureManager>
    <feature>microProfile-2.0</feature>
    <feature>localConnector-1.0</feature>
</featureManager>

有什么想法吗?

最佳答案

断路器已链接到实例。在您的示例中,您的 bean 是依赖作用域的,并且每个请求都有自己的断路器。如果更改为 ApplicationScoped,您应该会看到预期发生的情况。

关于java - WLP Microprofile 容错舱壁实现未启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52724051/

相关文章:

java - Java 中的 Fail fast finally 子句

scala - Akka OneForOneStrategy 不起作用

java - while-else-循环

java - 在一张图表上显示四组数据

java - 输出格式打印带有两位小数和占位符的逗号

apache-kafka - 使用 com.ibm.security.auth.module.Krb5LoginModule 时如何设置 JAAS serviceName

java - 如何设计:避免在随机访问文件时资源泄漏

java - 使用 JAX-RS Resteasy 和 ContainerRequestFilter/ContainerResponseFilter 记录请求

ibm-mobilefirst - 在 Worklight Console 中找不到运行时

java - 使用 Docker 容器查看 Java liberty Bluemix 应用程序时出现 502 错误