B.3 Configuring the Task Scheduler

In Spring Integration, the ApplicationContext plays the central role of a Message Bus, and there are only a couple configuration options to be aware of. First, you may want to control the central TaskScheduler instance. You can do so by providing a single bean with the name "taskScheduler". This is also defined as a constant:

 IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME 

By default Spring Integration uses the SimpleTaskScheduler implementation. That in turn just delegates to any instance of Spring's TaskExecutor abstraction. Therefore, it's rather trivial to supply your own configuration. The "taskScheduler" bean is then responsible for managing all pollers. The TaskScheduler will startup automatically by default. If you provide your own instance of SimpleTaskScheduler however, you can set the 'autoStartup' property to false instead.

When the endpoints are concurrency-enabled with their own 'taskExecutor' reference, the invocation of the handling methods will happen within that executor's thread pool and not the main scheduler pool. However, when no task-executor is provided for an endpoint's poller, it will be invoked in the dispatcher's thread (with the exception of subscribable channels where the subscribers will be invoked directly). The next section will describe what happens if Exceptions occur within the asynchronous invocations.