spring-scheduled

Stop KafkaListener ( Spring Kafka Consumer) after it has read all messages till some specific time

十年热恋 提交于 2021-02-10 15:05:54
问题 I am trying to schedule my consumption process from a single partition topic. I can start it using endpointlistenerregistry.start() but I want to stop it after I have consumed all the messages in current partition i.e. when I reach to last offset in current partition. Production into the topic is done after I have finished the consumption and close it. How should I achieve the assurance that I have read all the messages till the time I started scheduler and stop my consumer ? I am using

Stop KafkaListener ( Spring Kafka Consumer) after it has read all messages till some specific time

…衆ロ難τιáo~ 提交于 2021-02-10 15:02:11
问题 I am trying to schedule my consumption process from a single partition topic. I can start it using endpointlistenerregistry.start() but I want to stop it after I have consumed all the messages in current partition i.e. when I reach to last offset in current partition. Production into the topic is done after I have finished the consumption and close it. How should I achieve the assurance that I have read all the messages till the time I started scheduler and stop my consumer ? I am using

Is there way to use @Scheduled together with Duration string like 15s and 5m?

瘦欲@ 提交于 2021-01-27 05:28:32
问题 I have following annotation in my code @Scheduled(fixedDelayString = "${app.delay}") At this case I have to have properties like this app.delay=10000 #10 sec Propery file looks unreadable because I have calculate value to miliseconds. Is there way to pass value like 5m or 30s there ? 回答1: As far as I know, you can't do it directly. However, Spring boot configuration properties do support automatic conversion of parameters like 15s and 5m to Duration . This means you could create a

cron expression parsing into java date

╄→гoц情女王★ 提交于 2020-12-29 03:45:31
问题 my database having 10 18 16 ? * SUN,MON,WED,FRI * cron expression then how to convert into Java date. how to comparing with present day time. and one more is how to compare to cron expressions i.e. 10 18 16 ? * SUN,MON,WED,FRI * and 0 30 9 30 * ? please explain the sample code using quartz or spring scheduling. 回答1: Please use: import org.springframework.scheduling.support.CronSequenceGenerator; final String cronExpression = "0 45 23 * * *"; final CronSequenceGenerator generator = new

cron expression parsing into java date

余生长醉 提交于 2020-12-29 03:42:31
问题 my database having 10 18 16 ? * SUN,MON,WED,FRI * cron expression then how to convert into Java date. how to comparing with present day time. and one more is how to compare to cron expressions i.e. 10 18 16 ? * SUN,MON,WED,FRI * and 0 30 9 30 * ? please explain the sample code using quartz or spring scheduling. 回答1: Please use: import org.springframework.scheduling.support.CronSequenceGenerator; final String cronExpression = "0 45 23 * * *"; final CronSequenceGenerator generator = new

How to schedule a cron job in spring boot without using @Scheduled() annotation

拜拜、爱过 提交于 2020-12-05 12:10:42
问题 In spring boot, can I schedule a spring job by not using @Scheduled annotation to a method? I am working with spring job in the spring boot. I want to schedule a job by using cron expression, but without using @Scheduled(cron = " ") annotation to the method. I know that I can schedule a job inside this method as below. @Scheduled (cron = "0 10 10 10 * ?") public void execute() { / * some job code * / } But I want it to be dynamic so that I can take a cron expression as input from the user and