zoukankan      html  css  js  c++  java
  • 常用公共配置类——定时任务配置

    @Configuration
    public class ScheduleConfig {
    
        @Bean
        public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
            SchedulerFactoryBean factory = new SchedulerFactoryBean();
            factory.setDataSource(dataSource);
    
            //quartz参数
            Properties prop = new Properties();
            prop.put("org.quartz.scheduler.instanceName", "RenrenScheduler");
            prop.put("org.quartz.scheduler.instanceId", "AUTO");
            //线程池配置
            prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
            prop.put("org.quartz.threadPool.threadCount", "20");
            prop.put("org.quartz.threadPool.threadPriority", "5");
            //JobStore配置
            prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
            //集群配置
            prop.put("org.quartz.jobStore.isClustered", "true");
            prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
            prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
    
            prop.put("org.quartz.jobStore.misfireThreshold", "12000");
            prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
            prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
    
            //PostgreSQL数据库,需要打开此注释
            //prop.put("org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate");
    
            factory.setQuartzProperties(prop);
    
            factory.setSchedulerName("RenrenScheduler");
            //延时启动
            factory.setStartupDelay(30);
            factory.setApplicationContextSchedulerContextKey("applicationContextKey");
            //可选,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
            factory.setOverwriteExistingJobs(true);
            //设置自动启动,默认为true
            factory.setAutoStartup(true);
    
            return factory;
        }
    }
    一个小小后端的爬行痕迹
  • 相关阅读:
    Android数据适配器(Adapter)优化:高效ViewHolder
    touch-css-margintop问题
    抽奖
    scroll03-节日两侧的渲染
    scroll02-滚动时显示当前主题菜单状态
    浏览器背景色半透明效果。
    scroll01-滚动到一定高度时,显示导航栏
    layout01-在布局ul时,给li设置margin-right的时候,每行的最后一个li有margin-right 导致ul 看上去不居中的问题
    placehoder兼容
    day03
  • 原文地址:https://www.cnblogs.com/heikedeblack/p/14982024.html
Copyright © 2011-2022 走看看