quarkusjberet

Schedule a Job at later time in Quarkus JBeret


I use Quarkus implementation of JBeret and want to schedule a job i.e later in the day. So I use Scheduler with a SchedulerExpression. But the job is processed immediately after scheduling and not waiting until schedule time is reached. I searched in tests, but all tests use initialDelay, there is no test using ScheduledExpression.

` Properties properties = prepareJobCreation(currentJobName); properties.setProperty(BatchParamName.FIRST_DAY_PREV_YEAR, firstDayPrevYear);

    ScheduleExpression scheduleExpression = new ScheduleExpression();
    scheduleExpression.dayOfMonth(17);
    scheduleExpression.month(8);
    scheduleExpression.year(2024);
    scheduleExpression.hour(18);
    scheduleExpression.minute(1);
    scheduleExpression.second(0);
    final JobScheduleConfig scheduleConfig = JobScheduleConfigBuilder.newInstance()
            .jobName("jobname")
            .scheduleExpression(scheduleExpression)
            .jobParameters(properties)
            .build();

    jobScheduler.schedule(scheduleConfig);

` When running this code on September, 17th, 2024 17:50 job was processed at 17:50 and at 18:01 nothing occured.

I also tried to put 9 to month (instead of 8 as usually in Java) bot no success as well.

Is there a possibility in Quarkus JBeret to do this? Or am I doing wrong?


Solution

  • My guess is that ScheduleExpression is part of ejb api, which creates a cron schedule to be executed by ejb container, which may not be present in your quarkus.