I am currently trying to set up resque-scheduler for my rails 3 application. In my simple test application, I am trying to expire a token which is in my User model 10 seconds after it has been set.
In my TokenController's create method which is called to set the token, I use Resque.enqueue_in(10.seconds, ExpireToken, :user_id => @user.id) to enqueue a new job. The ExpireToken class looks like this:
class ExpireToken
@queue = :token
def self.perform(user_id)
user = User.find(user_id)
if not user.nil?
user.update_attribute(:authentication_token, nil)
else
raise
end
end
end
After starting up the resque server, rails server and starting a worker by using rake resque:work QUEUE=*, I see 0 queues being registered in the resque admin interface with 1 idle worker. As a result, I don't see any jobs since there are no queues.
In my redis server I do see some activity like this:
[1691] 02 Apr 00:07:51 - DB 0: 2 keys (0 volatile) in 4 slots HT.
[1691] 02 Apr 00:07:51 - 3 clients connected (0 slaves), 948880 bytes in use
How do I register the token queue?
It turns out the queue will not show up in the resque admin interface until the first job has been processed. In order for that to happen in resque-scheduler in my case, I had to do the following:
1) Start the rails server (to trigger the Resque.enqueue_in method inside one of my controller methods.
2) Start the redis server to start accepting workers and jobs.
3) Start the resque scheduler that will pull the delayed jobs (important!)
4) Start the resque worker that will handle the jobs coming in.
5) Enjoy watching the jobs get gobbled up in the interface!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With