Rails simple Newsletter / Mailing List with notification of new search results via email

泄露秘密 提交于 2019-12-13 04:12:21

问题


My users can save their preferred searches. Now I need to give them the possibility to subscribe to them in order to receive an email notification whenever new search results are available (like on Yahoo answers).

I already set up a Mailer that, when manually triggered, is working ok.

Now all I need to do is to call the mailer from a scheduled job but... I really ain't an expert on that field. So, among Whenever, Delayed_job, Sidekiq, Resque Scheduler & co. with which one (or combination of ones) should I go for this kind of task (long-running process with several mailing)?

EDIT

I developed a working example app, available on Github: NotiSearch.

It's pretty well documented so, if you are trying to develop something like it, I'd definitely recommend you to check it out.

PS: I chose to rely on whenever and delayed_job since they don't have external dependencies, if needed it should be easy enough to transition to a more scalable solution.


回答1:


I've personally worked with Resque and Sidekiq. The main difference between these two is that Sidekiq spawns new threads for each job.

Resque has a process per job. This just basically mean that Resque assumes failure and other jobs won't fail if one process fails. Sidekiq, since it works with threads, if one of those threads locks up for whatever reason the entire process will be locked up.

From an answer in another QA Resque vs Sidekiq?

Resque:

Pros:

does not require thread safety (works with pretty much any gem out there); has no interpreter preference (you can use any ruby); loads of plugins. Cons

runs a process per worker (uses more memory); does not retry jobs (out of the box, anyway). Sidekiq:

Pros

runs thread per worker (uses much less memory); less forking (works faster); more options out of the box. Cons

[huge] requires thread-safety of your code and all dependencies. If you run thread-unsafe code with threads, you're asking for trouble; much less plugins (at the moment there are only 2); works on some rubies better than others (jruby and rubinius are recommended, efficiency on MRI is decreased due to GVL (global VM lock)).

EDIT

Anyway to answer your question. In all the projects we've used mailers we use Resque.




回答2:


Try MailyHerald - mailing management gem for rails. It will allow you to set up periodical mailing sent to users only if specific conditions are met - i.e. new search results are available.

MailyHerald processes all mailings automatically in the background (using Sidekiq) and provides nice web-ui for management purposes.



来源:https://stackoverflow.com/questions/13313504/rails-simple-newsletter-mailing-list-with-notification-of-new-search-results-v

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!