队列大小没有getter,只有队列容量。
如果我使用jmx监视ThreadPoolTaskExecutor,我如何监视队列大小级别以确保它健康?
答案 0 :(得分:7)
executor.getThreadPoolExecutor().getQueue().size()
修改强>
@ManagedResource
public class MyTEMBean {
private final ThreadPoolTaskExecutor te;
public MyTEMBean(ThreadPoolTaskExecutor te) {
this.te = te;
}
@ManagedAttribute
public int getQueueSize() {
this.te.getThreadPoolExecutor().getQueue().size();
}
}