Nilesh Navale
Nilesh Navale

Reputation: 45

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

Upvotes: 0

Views: 2431

Answers (2)

meso_2600
meso_2600

Reputation: 2126

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

Upvotes: 0

Nilesh
Nilesh

Reputation: 1159

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 

Upvotes: 4

Related Questions