- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想在我的 Web 应用程序中使用 MP FaultTolerance 功能中的熔断功能。现在我不知道如何知道这个函数是否在我的应用程序中运行。我想自动跟踪 MP 容错添加的 MP 指标的值,如 https://download.eclipse.org/microprofile/microprofile-fault-tolerance-2.0/microprofile-fault-tolerance-spec.html#fallback 中所述。
我的应用程序在 WAS Liberty 配置文件 19.0.0.6 上运行。我尝试使用/metrics 获取所有指标,但仅返回基本指标。返回结果如下
# TYPE base:classloader_total_loaded_class_count counter
# HELP base:classloader_total_loaded_class_count Displays the total number of classes that have been loaded since the Java virtual machine has started execution.
base:classloader_total_loaded_class_count 8853
我导入了包 org.eclipse.microprofile.faulttolerance。将 CircuitBreaker 注释到我的 java 代码中,并在方法前面添加注释,如下所示:
@CircuitBreaker(successThreshold = 2, requestVolumeThreshold = 3, failureRatio = 0.5, delay = 1000)
public void handle() throws ApiRequesterException{
..........
}
我在 server.xml 中添加了如下功能
<featureManager>
<feature>mpFaultTolerance-1.1</feature>
<feature>mpMetrics-1.1</feature>
</featureManager>
ft.<name>.circuitbreaker.callsSucceeded.total
, ft.<name>.circuitbreaker.callsSucceeded.total
等等。最佳答案
看来您所做的一切都是正确的,因此有几种可能会导致您看不到指标:
只有调用该方法一次后,指标才会显示
您是否安装了所需的功能?
如果您没有同时安装 mpFaultTolerance-1.1 和 mpMetrics-1.1,服务器仍会启动,但您会在 messages.log 顶部收到一条警告,说明哪些功能无法启动或不存在。
容错是使用拦截器实现的。为了进行拦截,该方法需要位于 CDI bean 上,您需要使用 @Inject
将您的 bean 注入(inject)某处,然后需要在注入(inject)的实例上调用该方法。
特别是,在以下情况下不会发生拦截:
new
创建类的实例就测试断路器是否工作而言,最简单的方法通常是调用该方法并检查指标是否出现。除此之外,您需要使您的方法失败几次,并检查您是否开始收到 CircuitBreakerOpenException
。
关于java - 如何在 Liberty 配置文件中使用 MicroProfile FaultTolerance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57471610/
我正在测试 websphere liberty 的容错(microprofile)实现。因此,我制作了一个简单的 REST 服务,其中的资源会 hibernate 5 秒: @Path("clien
我想在我的 Web 应用程序中使用 MP FaultTolerance 功能中的熔断功能。现在我不知道如何知道这个函数是否在我的应用程序中运行。我想自动跟踪 MP 容错添加的 MP 指标的值,如 ht
我是一名优秀的程序员,十分优秀!