0

I wrote my job using jsr-352 and deployed it on wildfly. How can I schedule one job with some delay after last end time like below time line where = is execution time and - is delay time:

===============--=====--========--

Note: maximum number of job execution is one

mohammad_1m2
  • 1,571
  • 5
  • 19
  • 38

1 Answers1

1

JBeret ejb scheduler supports repeating interval job executions, with a fixed interval duration or certain delay duration after the start of job execution. Delay after end of a job execution is currently not supported. If your job execution duration is relatively predictable, you can approximate it with either interval or delay after the start of a job execution.

To achieve this kind of job schedulgin with finer control, you can try the following:

  • schedule a single-action job schedule
  • configure a job listener in job.xml to watch for the end of the above job execution, and scheule the next single-action job execution with a short initial delay
  • specifically, the job listener's afterJob() method should be able to look up or inject TimerSchedulerBean, which is a local singleton EJB, and invoke its org.jberet.schedule.TimerSchedulerBean#schedule method. The job listener is reponsible for creating an instance of org.jberet.schedule.JobScheduleConfig, passing it when calling the ejb business method. The job listener should already have all info to create JobScheduleConfig.
cheng
  • 1,076
  • 6
  • 6
  • Is there any listener example? can you introduce some links? – mohammad_1m2 Jan 28 '18 at 15:48
  • https://github.com/jberet/jsr352/tree/master/wildfly-jberet-samples/scheduleTimer is the test app for JBeret ejb scheduler. I'll explore if we can add similar use case to it. – cheng Jan 28 '18 at 16:04
  • See the above JBeret JIRA for details. I've added such a job listener (SchedulingJobListener) to jberet-schedule-executor module and should be formally available in next release. If you want to try it right now, you can copy this class to your application and should just work as well. – cheng Jan 29 '18 at 04:31