job when a delayed task fails so it will auto

Our app is hosted on heroku and we use delayed job when sending info to a remote system (via a GET to a url with some url params)

the remote system returns a success code usually, but it it;s real busy it returns a tryagain code.

suppose the our method is

def send_info
   the_url = "http://mydomain.com/dosomething?arg=#{self.someval}"
   the_result = open(the_url).read
   successflag = get_success_flag_from(the_result)
end

and so somewhere in our code we do

@widget.delay.send_info

and that all works fine.

Except it does not automatically handle the case where the remote said to try back later.

Is there any way for the send_info method (which is what delayed job will execute) to "tell" delayed_job "retry me again"? Do we need to throw some custom exception or something?


Raising any kind of exception ought to cause delayed_job to requeue it (subject to only-trying-so-many-times); if you don't especially need a custom exception you can just raise a RuntimeError .

链接地址: http://www.djcxy.com/p/65776.html

上一篇: 红宝石在轨道上

下一篇: 当延迟任务失败时进行作业,因此它会自动执行