#Does the EventDelegate works for scheduled jobs?

1 messages · Page 1 of 1 (latest)

thin musk
#

Redis is running and the jobs is executed. The delegate has been added to the notification hook. Something I miss?

thorn fossil
#

Yes, the JobEventDelegate (or async version thereof) should fire for scheduled jobs. Which queue notifications driver are you using?

thin musk
#

The redis driver.

#

How exactly does the delegate know for what exact job I want to be informed?

#

Maybe thats the part I miss

thorn fossil
#

Can you show how you configure the delegate and the hook?

thin musk
#

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

thorn fossil
#

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! 😆 😅

thin musk
#

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

thorn fossil
#

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)

thin musk
#

Should I draft an issue?

thorn fossil
#

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.

thin musk
#

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.

thin musk
#

So what I can see so far is, that in my case it never reaches the hook, cause there is no id to pop

#

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

thorn fossil
#

🤨 I didn't even realize there was a Redis 7 yet.

#

Got some CI to update 😆

thin musk
#

Could it be the issue? I cant cross-check

#

Maybe I can install the older version and see if its works

thorn fossil
#

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).

thin musk
#

You mean an update of the driver?

thorn fossil
#

Yeah.

thin musk
#

Kay, let me see if I understand whats LMOVE RIGHT LEFT means, then I can work on it

#

Oh, I see, it is not in our hands. The command is not listed yet in the repository of mordil.

thin musk
#

I am on 6.2 now and still nil when RPOPLPUSH vapor_queues[default] vapor_queues[default]-processing

#

So it must be something else. I dig further tomorrow