spring-scheduled

Schedule a task with Cron which allows dynamic update

六眼飞鱼酱① 提交于 2019-12-03 13:13:23
问题 I use sprint boot 1.3, spring 4.2 In this class @Service public class PaymentServiceImpl implements PaymentService { .... @Transactional @Override public void processPayment() { List<Payment> payments = paymentRepository.findDuePayment(); processCreditCardPayment(payments); } } I would like to call processPayment every x moment. This x moment is set in a database. The user can modify it. So i think i can't use anotation. I started to this this @EntityScan(basePackageClasses = {MyApp.class,

Difference between Quartz Job and Scheduling Tasks with Spring?

微笑、不失礼 提交于 2019-12-03 05:02:50
问题 I am new to Spring-boot(version 1.3.6) and Quartz and I am wondering what is the difference between making a task with Spring-scheduler: @Scheduled(fixedRate = 40000) public void reportCurrentTime() { System.out.println("Hello World"); } And the Quartz way: 0. Create sheduler. 1. Job which implements Job interface. 2. Create JobDetail which is instance of the job using the builder org.quartz.JobBuilder.newJob(MyJob.class) 3. Create a Triger 4. Finally set the job and the trigger to the

Difference between Quartz Job and Scheduling Tasks with Spring?

两盒软妹~` 提交于 2019-12-02 19:21:35
I am new to Spring-boot(version 1.3.6) and Quartz and I am wondering what is the difference between making a task with Spring-scheduler : @Scheduled(fixedRate = 40000) public void reportCurrentTime() { System.out.println("Hello World"); } And the Quartz way : 0. Create sheduler. 1. Job which implements Job interface. 2. Create JobDetail which is instance of the job using the builder org.quartz.JobBuilder.newJob(MyJob.class) 3. Create a Triger 4. Finally set the job and the trigger to the scheduler In code: public class HelloJob implements Job { public HelloJob() { } public void execute

java.lang.ClassNotFoundException: org.springframework.core.ResolvableTypeProvider [duplicate]

十年热恋 提交于 2019-12-01 06:45:53
This question already has an answer here: What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException? 15 answers I have written a Spring annotated scheduler program but when I execute it gives the error message in the post title. SchedulerConfig.java import java.util.concurrent.Executor; import java.util.concurrent.Executors; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation

java.lang.ClassNotFoundException: org.springframework.core.ResolvableTypeProvider [duplicate]

∥☆過路亽.° 提交于 2019-12-01 04:56:47
问题 This question already has answers here : What causes and what are the differences between NoClassDefFoundError and ClassNotFoundException? (15 answers) Closed 3 years ago . I have written a Spring annotated scheduler program but when I execute it gives the error message in the post title. SchedulerConfig.java import java.util.concurrent.Executor; import java.util.concurrent.Executors; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation

Spring @Scheduled cron details from property file - Exception

流过昼夜 提交于 2019-12-01 00:24:21
I was trying to define the cron details in my spring @Scheduled method @Service @PropertySource("classpath:application.properties") public class CacheRefreshService { @Scheduled(cron = "${api.refresh.cron}") public void refreshJob() throws Exception { LOGGER.info("Started Refresh"); //do something } } And in my application.properties #Refresh api.refresh.cron =0 29 11 * * ? When I define the cron details along with @Scheduled, it is running fine. But when I do this, it is not able to read the value from the properties file and the below error is thrown. Caused by: java.lang

Interrupt spring scheduler task before next invocation

久未见 提交于 2019-11-30 16:06:38
问题 I have a Spring-Boot application which is going to be an orchestration service for several other processes we want to trigger. I have it currently set up using Spring Scheduling pulling crons dynamically from a database. I threw in a rest method to trigger the process to pull new cron information from the database. This logic all works correctly. The only "issue" is that it doesn't use the new cron information until the next scheduled run which gets to the real question. Is there a way to

Interrupt spring scheduler task before next invocation

ε祈祈猫儿з 提交于 2019-11-30 15:43:15
I have a Spring-Boot application which is going to be an orchestration service for several other processes we want to trigger. I have it currently set up using Spring Scheduling pulling crons dynamically from a database. I threw in a rest method to trigger the process to pull new cron information from the database. This logic all works correctly. The only "issue" is that it doesn't use the new cron information until the next scheduled run which gets to the real question. Is there a way to interrupt the current Trigger and schedule one again using the updated cron information. Here is the

Spring update scheduler

别说谁变了你拦得住时间么 提交于 2019-11-30 07:55:32
I have a scheduled job in Spring, I get its cron from my database. Every time it is executed, the next execution time is updated. So, if it is configured to run every 10 minutes, I can change the value into the database to schedule that job every 15 minutes. The problem is that I have to wait for the execution to get the updated cron: if a job is scheduled every 15 minutes and I want to change this value to be every 2 minutes, I have to wait for the next execution (up to 15 minutes) to have this job every 2 minutes. Is there a way to get this job rescheduled after I update the database? I

Injecting externalized value into Spring annotation

五迷三道 提交于 2019-11-30 05:57:49
I've been thinking around the Java feature that evaluates annotation values in compile-time and it seems to really make difficult externalizing annotation values. However, I am unsure whether it is actually impossible, so I'd appreciate any suggestions or definitive answers on this. More to the point, I am trying to externalize an annotation value which controls delays between scheduled method calls in Spring, e.g.: public class SomeClass { private Properties props; private static final long delay = 0; @PostConstruct public void initializeBean() { Resource resource = new ClassPathResource(