Delete specific jobs and jobs created from rails console from a Resque queue

Devaraju Boddu
1 min readJul 22, 2020

We have Resque.destroy method allows you to define the queue to clean up and the class name of the job type you want removed. But if we create an job form the rails console and tried to delete that job will throw the error like uninitialised constant

The following call will remove all jobs of class UpdateGraph:

Resque::Job.destroy(queue, 'UpdateGraph')

You can also specify arguments to filter out certain jobs of that type:

Resque::Job.destroy(queue, 'UpdateGraph', 'foo')

Consider we’ve created job from the rails console and queued the job as blow

class UpdateTestGraph
@queue = :high
def self.perform
.........
end
end
Resque.enqueue(UpdateTestGraph)

Here these jobs will run in worker server where UpdateTestGraph class does not exist so which will raise error by saying Uninitialised constant UpdateTestGraph and this block the worker server to continue to run the other jobs in the queue

And at the time of deleting this job form the queue will raise the same error. To avoid this issue and delete the job form the queue need to initialise the UpdateTestGraph and call the Resque.destroy method

UpdateTestGraph = 1
Resque::Job.destroy(queue, 'UpdateTestGraph')

The above solution will workout for deleting the job from the rescue server

--

--

Devaraju Boddu

Technical Consultant | Ruby On Rails | Java | Spring Boot | AWS