Java Code Examples for org.springframework.scheduling.quartz.SimpleTriggerFactoryBean

The following examples show how to use org.springframework.scheduling.quartz.SimpleTriggerFactoryBean. These examples are extracted from open source projects. 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 Project: MyCommunity   Source File: QuartzConfig.java    License: 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 Project: MyCommunity   Source File: QuartzConfig.java    License: 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
@Bean(name = "firstTrigger")
public SimpleTriggerFactoryBean firstTrigger(JobDetail firstJobDetail) {
    SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
    trigger.setJobDetail(firstJobDetail);
    // 设置任务启动延迟
    trigger.setStartDelay(0);
    // 每5秒执行一次
    trigger.setRepeatInterval(3600000);//一小时
    return trigger;
}
 
Example 4
Source Project: spring-boot-quartz-demo   Source File: JobUtil.java    License: 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();
}
 
Example 5
Source Project: ehousechina   Source File: SchedulerConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean(name = "sampleJobTrigger")
public SimpleTriggerFactoryBean sampleJobTrigger(@Qualifier("sampleJobDetail") JobDetail jobDetail) {
	SimpleTriggerFactoryBean factoryBean = new SimpleTriggerFactoryBean();
	factoryBean.setJobDetail(jobDetail);
	factoryBean.setStartDelay(0L);
	factoryBean.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
	factoryBean.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT);
	return factoryBean;
}
 
Example 6
@Bean(name="simpleJobTrigger2")
public SimpleTriggerFactoryBean createSimpleTrigger2(@Qualifier("simpleJobDetail") JobDetail jobDetail) {
	Map<String, Object> map = new HashMap<>(1);
	map.put("myKey", "myValue");
	return QuartzUtils.createSimpleTrigger(jobDetail, "STName2", "STGroup2", "STDesc2", 10000L, 30000L,
			SimpleTrigger.REPEAT_INDEFINITELY,
			SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT, map, 1000);
}
 
Example 7
@Bean(name="simpleJobTrigger2")
public SimpleTriggerFactoryBean createSimpleTrigger2(@Qualifier("simpleJobDetail") JobDetail jobDetail) {
	Map<String, Object> map = new HashMap<>(1);
	map.put("myKey", "myValue");
	return QuartzUtils.createSimpleTrigger(jobDetail, "STName2", "STGroup2", "STDesc2", 10000L, 30000L,
			SimpleTrigger.REPEAT_INDEFINITELY,
			SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT, map, 1000);
}
 
Example 8
Source Project: mojito   Source File: BlobStorageConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Profile("!disablescheduling")
@Bean
public SimpleTriggerFactoryBean triggerExpiringBlobCleanup(@Qualifier("jobDetailDatabaseBlobStorageCleanupJob") JobDetail job) {
    logger.info("Configure jobDetailDatabaseBlobStorageCleanupJob");
    SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
    trigger.setJobDetail(job);
    trigger.setRepeatInterval(Duration.ofMinutes(5).toMillis());
    trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
    return trigger;
}
 
Example 9
Source Project: mojito   Source File: AssetExtractionCleanupJob.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleTriggerFactoryBean triggerAssetExtractionCleanup(@Qualifier("jobDetailAssetExtractionCleanup") JobDetail job) {
    SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
    trigger.setJobDetail(job);
    trigger.setRepeatInterval(Duration.ofMinutes(5).toMillis());
    trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
    return trigger;
}
 
Example 10
Source Project: mojito   Source File: PollableTaskCleanupJob.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleTriggerFactoryBean triggerPollableTaskCleanup(@Qualifier("jobDetailPollableTaskCleanup") JobDetail job) {
    SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
    trigger.setJobDetail(job);
    trigger.setRepeatInterval(REPEAT_INTERVAL);
    trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
    return trigger;
}
 
Example 11
Source Project: mojito   Source File: PluralFormUpdaterJob.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
SimpleTriggerFactoryBean triggerPluralFormUpdater(@Qualifier("jobDetailPluralFromUpdater") JobDetail job) {
    SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
    trigger.setJobDetail(job);
    trigger.setRepeatInterval(10000);
    trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
    return trigger;
}
 
Example 12
Source Project: mojito   Source File: RepositoryManualScreenshotRunJob.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleTriggerFactoryBean triggerRepositoryManualScreenshotRunJob(@Qualifier("repositoryManualScreenshotRun") JobDetail job) {
    SimpleTriggerFactoryBean simpleTriggerFactoryBean = new SimpleTriggerFactoryBean();
    simpleTriggerFactoryBean.setJobDetail(job);
    simpleTriggerFactoryBean.setRepeatCount(0);
    return simpleTriggerFactoryBean;
}
 
Example 13
Source Project: quartz-manager   Source File: SchedulerConfig.java    License: Apache License 2.0 5 votes vote down vote up
private static SimpleTriggerFactoryBean createTrigger(JobDetail jobDetail, long pollFrequencyMs,
		int repeatCount) {
	SimpleTriggerFactoryBean factoryBean = new SimpleTriggerFactoryBean();
	factoryBean.setJobDetail(jobDetail);
	factoryBean.setStartDelay(3000L);
	factoryBean.setRepeatInterval(pollFrequencyMs);
	factoryBean.setRepeatCount(repeatCount);
	factoryBean
	.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT);// in case of misfire, ignore all missed triggers and continue
	return factoryBean;
}
 
Example 14
public SimpleTriggerFactoryBean getSimpleTrigger() {
	return simpleTrigger;
}
 
Example 15
Source Project: spring-boot-starter-quartz   Source File: QuartzUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * creates a simple trigger builder. you have to call {@link #build()} afterwards to get the object
 */
public QuartzSimpleTriggerBuilder() {
	triggerFactoryBean = new SimpleTriggerFactoryBean();
}
 
Example 16
Source Project: spring-boot-starter-quartz   Source File: QuartzUtils.java    License: Apache License 2.0 4 votes vote down vote up
public SimpleTriggerFactoryBean getTriggerFactoryBean() {
	return triggerFactoryBean;
}
 
Example 17
@Bean(name="simpleJobTrigger")
public SimpleTriggerFactoryBean createSimpleTrigger(@Qualifier("simpleJobDetail") JobDetail jobDetail) {
	return QuartzUtils.createSimpleTrigger(jobDetail, null, null, "Simple trigger 1", 5000L, 60000L, null);
}
 
Example 18
@Bean(name="simpleJobTrigger")
public SimpleTriggerFactoryBean createSimpleTrigger(@Qualifier("simpleJobDetail") JobDetail jobDetail) {
	return QuartzUtils.createSimpleTrigger(jobDetail, null, null, "Simple trigger 1", 5000L, 60000L, null);
}
 
Example 19
@Bean(name = "callbackJobTrigger")
public SimpleTriggerFactoryBean createCallbackTrigger(@Qualifier("callbackJobDetail") JobDetail jobDetail) {
	return QuartzUtils.simpleTriggerBuilder().jobDetail(jobDetail).name("CallbackTrigger1").startDelay(5L)
			.repeatInterval(100L).repeatCount(20).getTriggerFactoryBean();
}
 
Example 20
@Bean(name = "callbackJobTrigger2")
public SimpleTriggerFactoryBean createCallbackTrigger2(@Qualifier("callbackJobDetail") JobDetail jobDetail) {
	return QuartzUtils.simpleTriggerBuilder().jobDetail(jobDetail).name("CallbackTrigger2").startDelay(5L)
			.repeatInterval(100L).repeatCount(20).getTriggerFactoryBean();
}
 
Example 21
@Bean(name = "callbackJobTrigger3")
public SimpleTriggerFactoryBean createCallbackTrigger3(@Qualifier("callbackJobDetail") JobDetail jobDetail) {
	return QuartzUtils.simpleTriggerBuilder().jobDetail(jobDetail).name("CallbackTrigger3").startDelay(5L)
			.repeatInterval(100L).repeatCount(20).getTriggerFactoryBean();
}
 
Example 22
Source Project: quartz-manager   Source File: SchedulerConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean(name = "jobTrigger")
public SimpleTriggerFactoryBean sampleJobTrigger(@Qualifier("jobDetail") JobDetail jobDetail,
		@Value("${job.frequency}") long frequency, @Value("${job.repeatCount}") int repeatCount) {
	return createTrigger(jobDetail, frequency, repeatCount);
}
 
Example 23
Source Project: spring-boot-starter-quartz   Source File: QuartzUtils.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * creates a SimpleTriggerFactoryBean regarding the parameters with {@link SimpleTrigger#REPEAT_INDEFINITELY} and
 * {@link SimpleTrigger#MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT}
 * 
 * @see QuartzUtils#createSimpleTrigger(JobDetail, String, String, String, long, long, int, int, Map, int)
 *  
 * @param jobDetail
 * @param triggerName (optional)
 * @param triggerGroup (optional)
 * @param triggerDescription (optional)
 * @param startDelay
 * @param repeatInterval
 * @param jobData (optional)
 * @return
 */
public static SimpleTriggerFactoryBean createSimpleTrigger(JobDetail jobDetail, String triggerName,
		String triggerGroup, String triggerDescription, long startDelay, long repeatInterval,
		Map<String, ?> jobData) {
	
	return QuartzUtils.simpleTriggerBuilder().jobDetail(jobDetail).name(triggerName).group(triggerGroup)
			.description(triggerDescription).startDelay(startDelay).repeatInterval(repeatInterval)
			.repeatCount(SimpleTrigger.REPEAT_INDEFINITELY)
			.misfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT)
			.putJobData(jobData).getTriggerFactoryBean();
}
 
Example 24
Source Project: spring-boot-starter-quartz   Source File: QuartzUtils.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * <br><br>
 * <code>
 * {@literal @}Bean<br>
 * public SimpleTriggerFactoryBean createSimpleTrigger({@literal @}Qualifier("simpleJobDetail") JobDetail jobDetail) {<br>
 *     return QuartzJobUtils.createSimpleTrigger(jobDetail, null, null, "Simple trigger 1", 5000L, 60000L, SimpleTrigger.REPEAT_INDEFINITELY,
 *     SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT, null, 1 );<br>
 * }<br>
 * </code>
 * 
 * @param jobDetail
 * @param triggerName (optional)
 * @param triggerGroup (optional)
 * @param triggerDescription (optional)
 * @param startDelay
 * @param repeatInterval for infinity: {@link SimpleTrigger#REPEAT_INDEFINITELY}
 * @param repeatCount
 * @param misfireInstruction {@link SimpleTrigger}
 * @param jobData (optional)
 * @param priority
 * @return
 */
public static SimpleTriggerFactoryBean createSimpleTrigger(
		JobDetail jobDetail, String triggerName, String triggerGroup, String triggerDescription,
		long startDelay, long repeatInterval, int repeatCount, int misfireInstruction, Map<String, ?> jobData, int priority) {
	
	return QuartzUtils.simpleTriggerBuilder().jobDetail(jobDetail).name(triggerName).group(triggerGroup)
			.description(triggerDescription).startDelay(startDelay).repeatInterval(repeatInterval)
			.repeatCount(repeatCount).misfireInstruction(misfireInstruction).putJobData(jobData).priority(priority)
			.getTriggerFactoryBean();
}