Example usage for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor getPoolSize

List of usage examples for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor getPoolSize

Introduction

In this page you can find the example usage for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor getPoolSize.

Prototype

public int getPoolSize() 

Source Link

Document

Return the current pool size.

Usage

From source file:com.github.liyp.rabbitmq.demo.Main.java

public static void main(String[] args) throws IOException, InterruptedException {
    // start spring context
    @SuppressWarnings({ "resource" })
    ApplicationContext context = new ClassPathXmlApplicationContext(
            "com/github/liyp/rabbitmq/demo/applicationContext.xml");

    RabbitTemplate rabbitTemplate = (RabbitTemplate) context.getBean("rabbitTemplate");
    for (int i = 0; i < 200; i++) {
        rabbitTemplate.convertAndSend("queue_one", "test queue 1 " + i);
        rabbitTemplate.convertAndSend("queue_two", new MsgBean("test queue 2 " + i));
    }//  w w  w  . j  ava  2s  .  c  o m
    Thread.sleep(5000);
    ThreadPoolTaskExecutor threadExe = (ThreadPoolTaskExecutor) context.getBean("taskExecutor");
    System.out.println(threadExe.getActiveCount());
    System.out.println(threadExe.getCorePoolSize());
    System.out.println(threadExe.getMaxPoolSize());
    System.out.println(threadExe.getPoolSize());
    System.out.println(threadExe.getThreadPoolExecutor().getCorePoolSize());

    // System.out.println("rsv: " +
    // rabbitTemplate.receiveAndConvert("queue_two"));
}