Pergunta

I have implemented resque queuing system in my rails app. I want to know the flow of resque job starting from enqueue to removed out from queue.

The traditional work flow, along with method used from gem is,
1. Resque enqueue the job(Resque::Job.create) ,
2. Job calls 'perform' method of class(Resque::Job.perform), and
3. Resque removes job from the queue.

I debugged gem to find out the method used in step 3, but I couldn't find it. Methods Resque::Job.destroy, Resque::Job.dequeue are not responsible for this task, as I debugged. Can anyone tell me the method using to remove job from queue
.
Please note that, I do NOT want to remove job explicitly, I want typical resque method which removes job from queue.

Thanks in advance.

Foi útil?

Solução

Resque actually uses 'dequeue' method to remove a job:

  def dequeue(klass, *args)
    Job.destroy(queue_from_class(klass), klass, *args)
  end

To pick a job from the queue for processing it uses the 'pop' method:

  def pop(queue)
    decode redis.lpop("queue:#{queue}")
  end 

Outras dicas

so if the worker fails (or we press ctrl+c) there is no trace of the removed job. I think job should only be lpoped only if the job is done without any exception

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top