I have Sidekiq up and running on a RoR application. All works great and jobs are queued up.
I have seen a lot of patterns as far as queuing up jobs but am curios about this pattern which I see in production and works well. It is idempotent, can work with multiple Sidekiq workers and the
email = Email::Message.find_by(id: id)
return unless email
return unless email.sent? # or something that marks it has been sent
Email::Message.triggered(60).ids.each do |id|
That's a good pattern to use. Something like this:
The only problem that might occur is if your database dies after the email is sent but before it can be marked as sent. In that case, you can get a double delivery but that should be exceedingly rare.