Java Code Examples for org.springframework.scheduling.quartz.SimpleTriggerFactoryBean#setName()

The following examples show how to use org.springframework.scheduling.quartz.SimpleTriggerFactoryBean#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuartzConfig.java    From MyCommunity with Apache License 2.0 5 votes vote down vote up
/**
     *注意 参数 alphaJobDetail 的名字要上下一致,这样当有多个
     *  JobDetailFactoryBean 实例时,Spring会优先根据
     *  名字匹配进行注入
     *
     */

    // 配置Trigger(SimpleTriggerFactoryBean, CronTriggerFactoryBean)
//    @Bean
    public SimpleTriggerFactoryBean alphaTrigger(JobDetail alphaJobDetail) {
        SimpleTriggerFactoryBean factoryBean = new SimpleTriggerFactoryBean();
        factoryBean.setJobDetail(alphaJobDetail);
        factoryBean.setName("alphaTrigger");
        factoryBean.setGroup("alphaTriggerGroup");
        factoryBean.setRepeatInterval(3000);  // 每 3 秒执行一次
        factoryBean.setJobDataMap(new JobDataMap());  // Trigger 底层以 JobDataMap() 数据类型保存Job的一些状态
        return factoryBean;
    }
 
Example 2
Source File: QuartzConfig.java    From MyCommunity with Apache License 2.0 5 votes vote down vote up
public SimpleTriggerFactoryBean postScoreRefreshTrigger(JobDetail postScoreRefreshJobDetail) {
        SimpleTriggerFactoryBean factoryBean = new SimpleTriggerFactoryBean();
        factoryBean.setJobDetail(postScoreRefreshJobDetail);
        factoryBean.setName("postScoreRefreshTrigger");
        factoryBean.setGroup("communityTriggerGroup");
//        factoryBean.setRepeatInterval(1000 * 60 * 5);  // 5分钟
        factoryBean.setRepeatInterval(1000 * 60 * 120);  // 2小时
        factoryBean.setJobDataMap(new JobDataMap());
        return factoryBean;
    }
 
Example 3
Source File: JobUtil.java    From spring-boot-quartz-demo with MIT License 5 votes vote down vote up
/**
 * Create a Single trigger.
 * 
 * @param triggerName Trigger name.
 * @param startTime Trigger start time.
 * @param misFireInstruction Misfire instruction (what to do in case of misfire happens).
 * 
 * @return Trigger
 */
protected static Trigger createSingleTrigger(String triggerName, Date startTime, int misFireInstruction){
	SimpleTriggerFactoryBean factoryBean = new SimpleTriggerFactoryBean();
    factoryBean.setName(triggerName);
    factoryBean.setStartTime(startTime);
    factoryBean.setMisfireInstruction(misFireInstruction);
    factoryBean.setRepeatCount(0);
    factoryBean.afterPropertiesSet();
    return factoryBean.getObject();
}