Examples of ThreadPoolTaskExecutor


Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(total);

        // setup a task executor to be able send the messages in parallel
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(5);
        executor.afterPropertiesSet();
        for (int i = 0; i < 5; i++) {
            final int threadCount = i;
            executor.execute(new Runnable() {
                public void run() {
                    int start = threadCount * 200;
                    for (int i = 0; i < 200; i++) {
                        try {
                            // do some random sleep to simulate spread in user activity
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

            consumer.stop();
        }
    }

    private void sendMessagesToQueue() throws Exception {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.afterPropertiesSet();
        executor.execute(new Runnable() {
            public void run() {
                for (int i = 0; i < 10; i++) {
                    // when this delay is removed, the seda endpoint has ordering issues
                    try {
                        // do some random sleep to simulate spread in user activity
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

        int total = 10000;
        final int group = total / 20;
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(total);

        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(20);
        executor.afterPropertiesSet();
        for (int i = 0; i < 20; i++) {
            final int threadCount = i;
            executor.execute(new Runnable() {
                public void run() {
                    int start = threadCount * group;
                    for (int i = 0; i < group; i++) {
                        try {
                            // do some random sleep to simulate spread in user activity
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

  }

  @Test
  public void threadNamePrefix() {
    BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class);
    ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
    executor.setThreadNamePrefix("testExecutor");
    executor.afterPropertiesSet();
    processorDefinition.getPropertyValues().add("executor", executor);
    ConfigurableApplicationContext context = initContext(processorDefinition);
    ITestBean testBean = context.getBean("target", ITestBean.class);
    testBean.test();
    testBean.await(3000);
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

      return new AsyncBean();
    }

    @Override
    public Executor getAsyncExecutor() {
      ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
      executor.setThreadNamePrefix("Custom-");
      executor.initialize();
      return executor;
    }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

      return new AsyncBeanWithExecutorQualifiedByName();
    }

    @Bean
    public Executor e1() {
      ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
      return executor;
    }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    }

    @Bean
    @Qualifier("e2")
    public Executor otherExecutor() {
      ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
      return executor;
    }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass());
  }

  private void testExecutor(String channelName, int corePoolSize, int maxPoolSize, int keepAliveSeconds) {

    ThreadPoolTaskExecutor taskExecutor =
        this.appContext.getBean(channelName + "Executor", ThreadPoolTaskExecutor.class);

    assertEquals(corePoolSize, taskExecutor.getCorePoolSize());
    assertEquals(maxPoolSize, taskExecutor.getMaxPoolSize());
    assertEquals(keepAliveSeconds, taskExecutor.getKeepAliveSeconds());
  }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    AbstractSubscribableChannel channel = this.customContext.getBean(
        "clientOutboundChannel", AbstractSubscribableChannel.class);

    assertEquals(3, channel.getInterceptors().size());

    ThreadPoolTaskExecutor taskExecutor = this.customContext.getBean(
        "clientOutboundChannelExecutor", ThreadPoolTaskExecutor.class);

    assertEquals(21, taskExecutor.getCorePoolSize());
    assertEquals(22, taskExecutor.getMaxPoolSize());
    assertEquals(23, taskExecutor.getKeepAliveSeconds());
  }
View Full Code Here

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

    AbstractSubscribableChannel channel = this.customContext.getBean(
        "brokerChannel", AbstractSubscribableChannel.class);

    assertEquals(4, channel.getInterceptors().size());

    ThreadPoolTaskExecutor taskExecutor = this.customContext.getBean(
        "brokerChannelExecutor", ThreadPoolTaskExecutor.class);

    assertEquals(31, taskExecutor.getCorePoolSize());
    assertEquals(32, taskExecutor.getMaxPoolSize());
    assertEquals(33, taskExecutor.getKeepAliveSeconds());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.