我有一个后台工作,使用 Sidekiq 连接到我的另一个服务,如下所示:
def perform(id)
user = ABCClient.instance.user(id)
...
end
有时这个 ABCClient 会宕机,在这种情况下我想重新安排“执行”工作。
像这样:
def perform(id)
begin
user = ABCClient.instance.user(id)
rescue => e
# Reschedule job
end
...
end
https://github.com/mperham/sidekiq/wiki/Scheduled-Jobs https://github.com/mperham/sidekiq/wiki/Scheduled-Jobs
rescue => e
self.class.perform_in(5.minutes, id)
end
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)