Package org.springframework.scheduling.concurrent

Examples of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor


  }

  @Bean
  public ThreadPoolTaskExecutor clientInboundChannelExecutor() {
    TaskExecutorRegistration reg = getClientInboundChannelRegistration().getOrCreateTaskExecRegistration();
    ThreadPoolTaskExecutor executor = reg.getTaskExecutor();
    executor.setThreadNamePrefix("clientInboundChannel-");
    return executor;
  }
View Full Code Here


  }

  @Bean
  public ThreadPoolTaskExecutor clientOutboundChannelExecutor() {
    TaskExecutorRegistration reg = getClientOutboundChannelRegistration().getOrCreateTaskExecRegistration();
    ThreadPoolTaskExecutor executor = reg.getTaskExecutor();
    executor.setThreadNamePrefix("clientOutboundChannel-");
    return executor;
  }
View Full Code Here

  }

  @Bean
  public ThreadPoolTaskExecutor brokerChannelExecutor() {
    ChannelRegistration reg = getBrokerRegistry().getBrokerChannelRegistration();
    ThreadPoolTaskExecutor executor;
    if (reg.hasTaskExecutor()) {
      executor = reg.taskExecutor().getTaskExecutor();
    }
    else {
      // Should never be used
      executor = new ThreadPoolTaskExecutor();
      executor.setCorePoolSize(0);
      executor.setMaxPoolSize(1);
      executor.setQueueCapacity(0);
    }
    executor.setThreadNamePrefix("brokerChannel-");
    return executor;
  }
View Full Code Here

    this.keepAliveSeconds = keepAliveSeconds;
    return this;
  }

  protected ThreadPoolTaskExecutor getTaskExecutor() {
    ThreadPoolTaskExecutor executor = (this.taskExecutor != null ? this.taskExecutor : new ThreadPoolTaskExecutor());
    executor.setCorePoolSize(this.corePoolSize);
    executor.setMaxPoolSize(this.maxPoolSize);
    executor.setKeepAliveSeconds(this.keepAliveSeconds);
    executor.setQueueCapacity(this.queueCapacity);
    executor.setAllowCoreThreadTimeOut(true);
    return executor;
  }
View Full Code Here

    public boolean isUseRouteBuilder() {
        return false;
    }

    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

        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

  }

  @Test
  public void testBufferedExecuteRejected() throws Exception {

    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(1);
    taskExecutor.setMaxPoolSize(1);
    taskExecutor.setQueueCapacity(0);
    taskExecutor.afterPropertiesSet();

    ThrottledTaskExecutor executor = new ThrottledTaskExecutor(taskExecutor, 10);
    service = new ExecutorCompletionService<String>(executor);

    service.submit(new Callable<String>() {
View Full Code Here

  @Override
  public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter,
      StepExecution stepExecution) throws Exception {
    final List<Future<StepExecution>> tasks = new ArrayList<Future<StepExecution>>();
    final Set<StepExecution> result = new HashSet<StepExecution>();
    final ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();

    int stepExecutionCount = jobRepository.getStepExecutionCount(stepExecution.getJobExecution().getJobInstance(), stepExecution.getStepName());

    boolean isRestart = stepExecutionCount > 1;

    Set<StepExecution> partitionStepExecutions = splitStepExecution(stepExecution, isRestart);

    for (StepExecution curStepExecution : partitionStepExecutions) {
      partitionStepNames.add(curStepExecution.getStepName());
    }

    taskExecutor.setCorePoolSize(threads);
    taskExecutor.setMaxPoolSize(threads);

    taskExecutor.initialize();

    for (final StepExecution curStepExecution : partitionStepExecutions) {
      final FutureTask<StepExecution> task = createTask(step, curStepExecution);

      try {
        taskExecutor.execute(task);
        tasks.add(task);
      } catch (TaskRejectedException e) {
        // couldn't execute one of the tasks
        ExitStatus exitStatus = ExitStatus.FAILED
            .addExitDescription("TaskExecutor rejected the task for this step.");
View Full Code Here

    factory = new FaultTolerantStepFactoryBean<String, String>();

    factory.setBeanName("stepName");
    factory.setTransactionManager(transactionManager);
    factory.setCommitInterval(3);
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(3);
    taskExecutor.setMaxPoolSize(6);
    taskExecutor.setQueueCapacity(0);
    taskExecutor.afterPropertiesSet();
    factory.setTaskExecutor(taskExecutor);

  }
View Full Code Here

    factory = new FaultTolerantStepFactoryBean<String, String>();

    factory.setTransactionManager(transactionManager);
    factory.setBeanName("stepName");
    factory.setCommitInterval(3);
    ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
    taskExecutor.setCorePoolSize(3);
    taskExecutor.setMaxPoolSize(6);
    taskExecutor.setQueueCapacity(0);
    taskExecutor.afterPropertiesSet();
    factory.setTaskExecutor(taskExecutor);

    factory.setSkipLimit(10);
    factory.setSkippableExceptionClasses(getExceptionMap(Exception.class));
View Full Code Here

TOP

Related Classes of org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor

Copyright © 2018 www.massapicom. 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.