I have used two methods to schedule the jobs. In method-1 I have used line-1 to schedule the job and in method-2 I have used line-2 to schedule the job. The problem I am facing is that method-1 is working fine but when I comment the line-1 and use method-2 instead the jobs doesn't get executed and I get the error as described below.
[redisson-3-52] ERROR org.redisson.RedissonRemoteService - Can't execute: RemoteServiceRequest [requestId=010c22ce1141604daa2fbe2c7d8254f5b0, methodName=schedule, signatures=[[java.lang.String, [B, [B, long, java.lang.String, java.lang.String, java.lang.String]], args=[com.webengage.MRunnableTask, [B@746aebd, [B@9815025, 1529393160000, 0 56 12 19 JUN ? 2018, 5ede66a4-83f0-4a19-b742-f126e7173a4d, 010c22ce1141604daa2fbe2c7d8254f5b0], options=RemoteInvocationOptions[ackTimeoutInMillis=null, executionTimeoutInMillis=null], date=1529393122775]
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.redisson.RedissonRemoteService.invokeMethod(RedissonRemoteService.java:347)
at org.redisson.RedissonRemoteService.access$400(RedissonRemoteService.java:66)
at org.redisson.RedissonRemoteService$2.run(RedissonRemoteService.java:312)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at org.redisson.executor.TasksRunnerService.schedule(TasksRunnerService.java:124)
... 12 more
@jackygurui @mrniko kindly look into this.
I am using redisson 3.7.2 in standalone mode and redis 4.0.9.
Well, your cron expresion is for a specific time and date.
Usually you use cron to schedule repeating tasks, that should for examble run every 15 minutes.
Or another Example run once a day.
Your expression is valid, just means its parsable, it doesn't mean it realy schedules something.
Here is a generator I like to use, maybe it could help you understand it a bit more, or help you find the expression you want.
https://crontab-generator.org/
@mrniko
I spent some more time into this, I think I know the root cause of this exception.
When I try to schedule a task with a cron like "0 44 12 30 JUN ? 2018" which, like earlier comments, mean that it will fire only once in the future.
The execution flow comes at https://github.com/redisson/redisson/blob/master/redisson/src/main/java/org/redisson/executor/TasksRunnerService.java#L123 to execute the task. It does 2 things in the sequence given below
It schedules the Task's next run
Executes the task for current run
At step 1 the nextStartDate
comes back as null (As kind of expected), and scheduling the next run with null
value throws this error. In the current flow, it also misses the current run's execution as well (because step 1 has already thrown the exception)
Given this, I recommend one of the two solutions
Do not schedule the next run if nextStartDate
comes back as null (This may need to handled at multiple places for eg. when the initial schedule itself is never going to fire ever say "0 44 12 30 JUN ? 2017")
Switch the sequence of execution so that we execute the Task first. (people can handle this exception in their code)
More preferably, introduce the concept on 'NeverFireException' of sorts, which is handled by Quartz very gracefully where it doesn't let us schedule the task at all if its never going to file
@mrniko
I think one major point in this issue is being missed. The cron expression validation is not the only thing for which I created the issue.
The main point is that for any cron expression that will have finite no. of execution will not be executed for the last time.
Example:
1st of every month in 2018.
you can reproduce this issue very easily with expression 0 15,18 9 26 JUN ? 2018
this schedule should ideally execute twice, but it will execute only once.
Kindly go through the previous comment more carefully, I have mentioned the exact problem which is there in the code that is causing this error.
I think this issue is very critical and hence we should fix this on very high priority.