gpt4 book ai didi

Spring框架监控ThreadPoolTask​​Executor队列大小

转载 作者:行者123 更新时间:2023-12-03 18:15:14 25 4
gpt4 key购买 nike

我查了 http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutor.html

没有队列大小的 setter/getter ,只有队列容量。

如果我使用 jmx 来监控 ThreadPoolTask​​Executor,我如何监控队列大小级别以确保它是健康的?

最佳答案

executor.getThreadPoolExecutor().getQueue().size()
编辑

@ManagedResource
public class MyTEMBean {

private final ThreadPoolTaskExecutor te;

public MyTEMBean(ThreadPoolTaskExecutor te) {
this.te = te;
}

@ManagedAttribute
public int getQueueSize() {
return this.te.getThreadPoolExecutor().getQueue().size();
}

}

关于Spring框架监控ThreadPoolTask​​Executor队列大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40115747/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com