Is there any way to add some args in the *args parameter of resque enqueue method in the before_enqueue method and pass the added arguments to before_perform method.?
Or is there any way to send some data from before_enqueue method to before_perform method independently?
eg:
class Action
:queue queueName
def self.before_enqueue(*args)
param1 = 1
param2 = 2
args.push(param1, param2)
# I know this is not the correct way as args is a local variable here.
#But something like this
end
def self.before_perform(*args)
puts args.inspect # I need the added args here
end
def self.perform(params)
#some code here
end
end
Found that we can't add extra arguments in before_enqueue. But instead we can modify existing arguments. So, we can pass an empty hash as argument in the enqueue call and add arguments as key value pairs into this empty hash at before_enqueue. I'm talking everything with respect to Resque 1.20.0
Call to the enqueue method:
Resque.enqueue(class_name, {})
Inside the resque perform class:
self.before_enqueue(*args)
args[0][:param1] = 1
args[0][:param2] = 2
end
The above args will be available in before_perform as well.