Search code examples
ruby-on-railsresquerails-activejob

How to delete Resque ActiveJob Queue


I am using Resque with Redis as the queuing backend via ActiveJob. How do I clear all queues to prevent jobs from running again.

From the docs, I see that I can do

Resque::Job.destroy(queue_name, "Job_CLass_Name")

So in my case, I'm using a default queue and my Job class name is NotificationJob, this is what I'm doing from the console on Heroku:

Resque::Job.destroy("default", "NotificationJob")

but it's not working


Solution

  • ActiveJob uses a wrapper class around your job class. So for Resque, the wrapper class name is ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper.

    For the queue name, I'll advise you check the available queues you have via Resque.queues. Sometimes, the environment name will be appended to the default queue name. So in your case, you can try:

    Resque.destroy("#{environment_name}_default", "ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper")
    

    Hopefully, this helps