Example usage for org.springframework.scheduling.concurrent ConcurrentTaskExecutor ConcurrentTaskExecutor

List of usage examples for org.springframework.scheduling.concurrent ConcurrentTaskExecutor ConcurrentTaskExecutor

Introduction

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

Prototype

public ConcurrentTaskExecutor(@Nullable Executor executor) 

Source Link

Document

Create a new ConcurrentTaskExecutor, using the given java.util.concurrent.Executor .

Usage

From source file:com.github.mrstampy.gameboot.concurrent.GameBootConcurrentConfiguration.java

/**
 * Task executor./*w w w.j a  va2 s  . c o m*/
 *
 * @return the task executor
 */
@Bean(name = GAME_BOOT_TASK_EXECUTOR)
public TaskExecutor taskExecutor() {
    String name = isEmpty(taskExecutorName) ? "GameBoot Task Executor" : taskExecutorName;

    GameBootThreadFactory factory = new GameBootThreadFactory(name);

    Executor exe = Executors.newFixedThreadPool(taskExecutorPoolSize, factory);

    return new ConcurrentTaskExecutor(exe);
}

From source file:org.springframework.integration.kafka.listener.QueueingMessageListenerInvoker.java

public QueueingMessageListenerInvoker(int capacity, final OffsetManager offsetManager, Object delegate,
        final ErrorHandler errorHandler, Executor executor, boolean autoCommitOnError) {
    this.capacity = capacity;
    this.autoCommitOnError = autoCommitOnError;
    if (delegate instanceof MessageListener) {
        this.messageListener = (MessageListener) delegate;
        this.acknowledgingMessageListener = null;
    } else if (delegate instanceof AcknowledgingMessageListener) {
        this.acknowledgingMessageListener = (AcknowledgingMessageListener) delegate;
        this.messageListener = null;
    } else {// w w  w.  j a v  a  2s.com
        // it's neither, an exception will be thrown
        throw new IllegalArgumentException("Either a " + MessageListener.class.getName() + " or a "
                + AcknowledgingMessageListener.class.getName() + " must be provided");
    }
    this.offsetManager = offsetManager;
    this.errorHandler = errorHandler;
    if (executor != null) {
        this.executorService = new ExecutorServiceAdapter(new ConcurrentTaskExecutor(executor));
    } else {
        this.executorService = Executors.newSingleThreadExecutor();
    }
}