Spring framework monitoring ThreadPoolTaskExecutor queue size

青春壹個敷衍的年華 提交于 2021-02-07 14:01:07

问题


I checked http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/concurrent/ThreadPoolTaskExecutor.html

There is no getter for queue size, only queue capacity.

If I use jmx to monnitor ThreadPoolTaskExecutor, how can I monitor queue size level to make sure it is healthy?


回答1:


executor.getThreadPoolExecutor().getQueue().size()

EDIT

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

}


来源:https://stackoverflow.com/questions/40115747/spring-framework-monitoring-threadpooltaskexecutor-queue-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!