0

Given a user model and a post model, what is the best way to send mass email to all users when a new post is made without it clogging the application process?

Putting it in the controller halts the application. I was also looking into Active Job but it seems that it is not event driven.

C.Kraz
  • 483
  • 1
  • 4
  • 10

1 Answers1

0

You'll want to use a queue like ActiveJob anytime your Rails app needs to do something that is:

  • long-running
  • relies on another application that might fail or be unavailable

Queueing the email job lets your application respond quickly (e.g. "message being sent") and ensures that it won't be lost if the email server is down. Use a callback to do whatever you need after the message is queued or sent (e.g. email "Message Delivered").

Fordini
  • 79
  • 3