edi
edi

Reputation: 233

Spring framework monitoring ThreadPoolTaskExecutor queue size

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?

Upvotes: 10

Views: 7295

Answers (1)

Gary Russell
Gary Russell

Reputation: 174564

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

}

Upvotes: 15

Related Questions