Subversion Repositories SmartDukaan

Rev

Rev 30403 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.smartdukaan.cron.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

@Configuration
public class SchedulerConfig implements SchedulingConfigurer {
        /**
         * The pool size.
         */
        private final int POOL_SIZE = 10;

        /**
         * Configures the scheduler to allow multiple pools.
         *
         * @param taskRegistrar The task registrar.
         */
        @Override
        public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
                ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();

                threadPoolTaskScheduler.setPoolSize(POOL_SIZE);
                threadPoolTaskScheduler.setThreadNamePrefix("scheduled-task-pool-");
                threadPoolTaskScheduler.initialize();

                taskRegistrar.setTaskScheduler(threadPoolTaskScheduler);
        }
}