#Does the EventDelegate works for scheduled jobs?
1 messages · Page 1 of 1 (latest)
Yes, the JobEventDelegate (or async version thereof) should fire for scheduled jobs. Which queue notifications driver are you using?
The redis driver.
How exactly does the delegate know for what exact job I want to be informed?
Maybe thats the part I miss
Can you show how you configure the delegate and the hook?
Yup. One moment. Jumping to my desk
application.queues.schedule(PluginJob()).daily().at(.midnight)
application.queues.schedule(UpdateJob()).daily().at(.midnight)
application.queues.add(UpdateEventDelegate())
try application.queues.startInProcessJobs()
try application.queues.startScheduledJobs()
struct UpdateEventDelegate: AsyncJobEventDelegate {
func dispatched(job: JobEventData) async throws {
print("dispatched")
}
func didDequeue(jobId: String) async throws {
print("dispatched")
}
func success(jobId: String) async throws {
print("dispatched")
}
func error(jobId: String, error: Error) async throws {
print("dispatched")
}
}
So at the moment nothing fancy here
Just some prints, to asure it gets triggered
I have two jobs running. One to fetch the wordpress plugins and the second to fetch plugin updates, but I only want to be informed if there is an update needed
pages through the code of queues a bit...
Whooopsy. Jimmy didn't add the notification hooks to the scheduled jobs dispatch.
Congratulations, you have found a bug! 😆 😅
I think it does not matter, but I wanted to give you some context.
Anyway, in my head, I think I need some connection between the delegate and the job, do I?
Ah XD, how did you find it so fast? I was looking too
It's in QueuesCommand.swift - Look at startJobs(); it calls QueueWorker.run(), which includes the callouts to the notification hooks. But if you look at startScheduledJobs(), it calls schedule(), which ultimately (when the schedule hits) calls ScheduledJob.run(), which doesn't go through the QueueWorker machinery at all (why not?)
In fact, as far as I can see, scheduled jobs never actually go through the queuing system to begin with.
(which means they only apply in the process they're scheduled within, and don't persist across restarts or get distributed across multiple workers)
Should I draft an issue?
Please do!
I may try to corner Jimmy into fixing it (since it's his fault), but he probably won't, and I have a lot of Fluent work to do 😕
There is one workaround trick you can try.
When you schedule a job, don't schedule the real job - schedule a job that then does nothing but add the real job to the queue as an immediate job. Then it'll go through the whole system, including notifications.
Allrighty, @vague fable ping you here as you stumbled across the issue in the past, too.
Thank you Gwynne. Glad we found something. If you oversee my patch, than I am fine doing it.
So what I can see so far is, that in my case it never reaches the hook, cause there is no id to pop
It ends in the redis driver with https://redis.io/commands/rpoplpush/
Returns the last element of a list after removing and pushing it to another list. Deletes the list if the last element was popped.
Its says its deprecated and I use redis 7.0.11
The yield - at least - of the redis data is null, therefore no job identifier and so on
Could it be the issue? I cant cross-check
Maybe I can install the older version and see if its works
The Redis driver is tested against the latest Redis 6
RPOLPUSH is easily replaced with LMOVE RIGHT LEFT, but the latter only exists since Redis 6.2, and the driver supports back to Redis 4, I think (though personally I'd be more than happy to bump the requirement to 6.2 or higher).
You mean an update of the driver?
Yeah.