I want to define my Queue and it's process function in a different module. In another module I import the exported queue object and I call myQueue.add('example-data-params')
In redis I can see it actually adds these jobs, but all of them fail with the reason
Missing process handler for job type example-data-params
Isn't that possible?
File A:
import { myQueue } from '../jobs/xy'
myQueue.add('example-data-params')
File B:
export const myQueue = new Queue('refresh users')
myQueue.process(400, processExample)
function processExample(job) {
console.log('ok')
return
}
Edit: Before I tried instead of export + import to create a new Queue with the same name and use that new object to add jobs on. The outcome was exactly the same -> Jobs were added tor edis but all showed up as failed because of a "missing process function"
Edit 2: I just saw in the documentation that you've added a new parameter for the queue.add method. The first parameter is the name. The typings at definetelyTyped seem to be outdated as they don't show the name parameter there. I've fixed the typing to add(name?: string, data?: any, opts?: JobOptions): Promise<Job>;
Adding jobs following that pattern does still lead to the same error though.
As you can see in the signature, the first parameter is the name of the job. You need a handler that is defined for that name like this:
queue.process('example-data-params', (job) => ... );
I see, the typings for that need to be updated as well for @types/bull then.
Assuming I created named jobs and define the processor like this:
myQueue.process(400, processExample) it wouldn't process the named jobs at all then?
no, you need to define a processor for every named job as explained above.
Most helpful comment
As you can see in the signature, the first parameter is the name of the job. You need a handler that is defined for that name like this: