stitchng / adonis-queue

An addon/plugin package to provide driver-based job queueing services in AdonisJS 4.0+
MIT License
34 stars 9 forks source link

the queue is not running on the redis #12

Open farshadfahimi opened 3 years ago

farshadfahimi commented 3 years ago

I have a simple job like below

'use strict'

const Job = use('Job')

class Test extends Job {

    constructor(){
      super(arguments)

      this.timeOut = 2000; // seconds: time out for queue
      this.retryCount = 0; // number of times to retry
      this.retryUntil = 200; // seconds: retry
      this.delayUntil = 0; // seconds: delay
    }

    get queue () {
        return 'high'
    }

    async handle(link, done) {
        // ...
        console.log(`Job [${this.constructor.name}] - handler called: status=running; id=${this.id} `)
    }

    progress(progress) {
        // ...
        console.log(`Job [${this.constructor.name}] - progress:${progress}%: status=running; id=${this.id} `)
    }

    failed(error) {
        // ...
        console.log(`Job [${this.constructor.name}] - status:failed; id=${this.id} `, error.message)
    }

    retrying(error){
        // ...
        console.log(`Job [${this.constructor.name}] - status:retrying; id=${this.id} `, error.message)
    }

    succeeded(result){
        // ...
        console.log(`Job [${this.constructor.name}] - status:succeeded; id=${this.id} `, result)
    }
}

module.exports = Test

and simple in my controller just write the code for test the queue queue.dispatch(new Test()) when this action is call in the console I got the below log

@@adonisjs/Queue: [Redis] Queue [high] now ready

but the handler method is not running and when I'm checking the redis the keys is empty.

the configoration of the queue is default config without any changes.

How should I run the queue ?

isocroft commented 3 years ago

Hello @farshadfahimi . What version of adonis-queue are you using and did you follow all the instructions in the instructions.md file ?

alfianazizi commented 3 years ago

i'm experiencing the same issue with version 0.1.10, followed the instructions in theinstructions.md.

at first, the queue is working and handling the job just fine, buat after some time it only outputs

@@adonisjs/Queue: [Redis] Queue [high] now ready

I'm running the queue with adonis events as example. did i miss something important?

isocroft commented 3 years ago

@alfianazizi can you try to zero out the timeOut. Also, return true from the handle() method

Like so:


'use strict'

const Job = use('Job')

class Test extends Job {

    constructor(){
      super(arguments)

      this.timeOut = 0; // seconds: time out for queue
      this.retryCount = 0; // number of times to retry
      this.retryUntil = 200; // seconds: retry
      this.delayUntil = 0; // seconds: delay
    }

    get queue () {
        return 'high'
    }

    async handle(link, done) {
        // ...
        console.log(`Job [${this.constructor.name}] - handler called: status=running; id=${this.id} `)
        return true;
    }
azproweb commented 3 years ago

Same issue.

From package.json:

"dependencies": {
    "@adonisjs/ace": "^5.0.8",
    "@adonisjs/auth": "^3.0.7",
    "@adonisjs/bodyparser": "^2.0.5",
    "@adonisjs/cors": "^1.0.7",
    "@adonisjs/fold": "^4.0.9",
    "@adonisjs/framework": "^5.0.9",
    "@adonisjs/ignitor": "^2.0.8",
    "@adonisjs/lucid": "^6.1.3",
    "@adonisjs/mail": "^3.0.10",
    "@adonisjs/session": "^1.0.27",
    "@adonisjs/shield": "^1.0.8",
    "@adonisjs/validator": "^5.0.6",
    "adonisjs-queue": "^0.1.10"
}