Determine current queue from job

70 views Asked by At

I am on my way implementing some logging of resque activity using the resque hooks, e.g.:

def before_perform_log_start(*args)
  logger.info("Job #{self.to_s} started on queue #{queue_name}") # pseudo implementation
end

Now I want to include the queue on which the job is actually running. The naive approach would be to simply read the @queue instance variable, since we usually set that to indicate the jobs queue. However, any caller can override the queue using enqueue_to:

Resque.enqueue_to('foobar', MyJob)

So my question is: Can I determine the queue from which the job was actually pulled?

In the stacktrace I can see that my job's perform method is called by an instance of Resque::Job, which has an accessor for the queue. However, I see no way to obtain that job instance.

0

There are 0 answers