开发者

How resque removes job from the queue?

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 tra开发者_StackOverflowditional 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.


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 


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜