Package org.springframework.core.task

Examples of org.springframework.core.task.SimpleAsyncTaskExecutor


  @Test
  public void testMultithreadedSkipInWriter() throws Exception {
    writer.setFailures("1", "2", "3", "4", "5");
    factory.setCommitInterval(3);
    factory.setSkipLimit(10);
    factory.setTaskExecutor(new SimpleAsyncTaskExecutor());

    Step step = factory.getObject();

    step.execute(stepExecution);
    assertEquals(BatchStatus.COMPLETED, stepExecution.getStatus());
View Full Code Here


  int count = 0;

  // @Override
  public RepeatTemplate getRepeatTemplate() {
    TaskExecutorRepeatTemplate template = new TaskExecutorRepeatTemplate();
    template.setTaskExecutor(new SimpleAsyncTaskExecutor());
    // Set default completion above number of items in input file
    template.setCompletionPolicy(new SimpleCompletionPolicy(8));
    return template;
  }
View Full Code Here

  @Test
  public void testEarlyCompletionWithException() throws Exception {

    TaskExecutorRepeatTemplate template = new TaskExecutorRepeatTemplate();
    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    template.setCompletionPolicy(new SimpleCompletionPolicy(20));
    taskExecutor.setConcurrencyLimit(2);
    template.setTaskExecutor(taskExecutor);
    try {
      template.iterate(new RepeatCallback() {
                @Override
        public RepeatStatus doInIteration(RepeatContext context) throws Exception {
View Full Code Here

  @Test
  public void testExceptionHandlerSwallowsException() throws Exception {

    TaskExecutorRepeatTemplate template = new TaskExecutorRepeatTemplate();
    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    template.setCompletionPolicy(new SimpleCompletionPolicy(4));
    taskExecutor.setConcurrencyLimit(2);
    template.setTaskExecutor(taskExecutor);

    template.setExceptionHandler(new ExceptionHandler() {
            @Override
      public void handleException(RepeatContext context, Throwable throwable) throws Throwable {
View Full Code Here

  public void testThrottleLimit() throws Exception {

    int throttleLimit = 600;

    TaskExecutorRepeatTemplate template = new TaskExecutorRepeatTemplate();
    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    taskExecutor.setConcurrencyLimit(300);
    template.setTaskExecutor(taskExecutor);
    template.setThrottleLimit(throttleLimit);

    final String threadName = Thread.currentThread().getName();
    final Set<String> threadNames = new HashSet<String>();
View Full Code Here

   */
  @Test
  public void testSingleThreadAsynchronousExecution() throws Exception {
    TaskExecutorRepeatTemplate jobTemplate = new TaskExecutorRepeatTemplate();
    final RepeatTemplate stepTemplate = new RepeatTemplate();
    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    taskExecutor.setConcurrencyLimit(2);
    jobTemplate.setTaskExecutor(taskExecutor);

    final String threadName = Thread.currentThread().getName();
    final Set<String> threadNames = new HashSet<String>();

View Full Code Here

  @Before
  public void setUp() {

    template = new TaskExecutorRepeatTemplate();
    TaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    threadPool.setMaxPoolSize(300);
    threadPool.setCorePoolSize(10);
    threadPool.setQueueCapacity(0);
    threadPool.afterPropertiesSet();
    taskExecutor = threadPool;
View Full Code Here

  @Test
  public void testThrottleLimitEarlyFinishOneThread() throws Exception {

    early = 4;
    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    taskExecutor.setConcurrencyLimit(1);

    // This is kind of slow with only one thread, so reduce size:
    throttleLimit = 10;
    total = 20;
View Full Code Here

        listenerContainer.setMaxConcurrentConsumers(maxConcurrency);
      }
    }
    listenerContainer.setPrefetchCount(properties.getPrefetchCount(this.defaultPrefetchCount));
    listenerContainer.setTxSize(properties.getTxSize(this.defaultTxSize));
    listenerContainer.setTaskExecutor(new SimpleAsyncTaskExecutor(queue.getName() + "-"));
    listenerContainer.setQueues(queue);
    int maxAttempts = properties.getMaxAttempts(this.defaultMaxAttempts);
    if (maxAttempts > 1) {
      RetryOperationsInterceptor retryInterceptor = RetryInterceptorBuilder.stateless()
          .maxAttempts(maxAttempts)
View Full Code Here

            return new RestTemplate();
        }

        @Bean
        public TaskExecutor taskExecutor() {
            return new SimpleAsyncTaskExecutor();
        }
View Full Code Here

TOP

Related Classes of org.springframework.core.task.SimpleAsyncTaskExecutor

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.