Search code examples
ruby-on-railsresque

Events for background processing like Resque?


Is there a existing way to have Resque return a result after a worker is done processing much like with evented callbacks in node.js?


Solution

  • I think you want to look at resque after_perform hooks for job which will give you indication that job is processed / completed

    something like this inside your job

    class MyJob 
      @queue = :my_job
    
      def self.perform(*args)
        .... your perform code ...
      end
    
      def self.after_perform(*args)
        ... Write some code to setup a channel ..
      end 
    
    end
    

    This way the after_perform hook would be executed after the perform action is completed/processed signifying the completion of the job

    What I would suggest is to set up a channel(either using pub/sub or list) between your application and resque job and subscribe/pull that data across to your application where you can identify based on payload that job was completed/processed

    Hope this help

    Thanks you