Lets say I have this sidekiq worker:
def perform post_id
post = Post.find post_id
post.do_something
end
What would happen if the post was not found and an exception was raised?
Will sidekiq try again?
What would be a better design so that sidekiq would not try again without using sidekiq_options :retry => false
Thanks!
If you don't want an exception raised, use find_by_id
instead, which returns nil
if the record doesn't exist, rather than raising an exception. Be sure to check for nil
, though:
def perform post_id
post = Post.find_by_id post_id
post.do_something if post
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.