9

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

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

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

4

1 回答 1

15

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();
    }

}
于 2016-10-18T19:47:47.907 回答