14

When running UserMailer.new.perform, my mailer is sent and I get an email almost right away, but when I use UserMailer.perform_async, it spits back an object number and I never receive an email.

Can someone please tell me why this is happening and what the difference between these two methods are?

sclem72
  • 466
  • 6
  • 16
  • Not a lot of detail to go on here, but usually you're using sidekiq in conjunction with a worker queue, like Redis. The way sidekiq works is that instead of sending the mail in your application code, it will send some information about the job to a worker queue. Are you using redis or something like that? – Haymaker87 Jan 04 '16 at 16:25
  • Yes, I have redis and sidekiq running. – sclem72 Jan 04 '16 at 16:28
  • Check out this SO post http://stackoverflow.com/questions/12816226/sidekiq-worker-not-getting-triggered What is your sidekiq log saying? Is a job getting added to the queue in Redis? – Haymaker87 Jan 04 '16 at 16:37
  • What is `UserMailer`? Can you please include the code here. – Ryan Bigg Jan 04 '16 at 20:43
  • The difference is that with perform() you would be running the code on the rails server in the "frontend" (puma server), while with perform_async() you are using message queue (Redis) to pass the work to a worker process (Sidekiq). Sidekiq polls the message queue, picks up the work from the queue, and runs it on the worker. You are probably having some issue with the Redis configuration, for example having REDIS_DB = 0 on the rails server and REDIS_DB = 1 on Sidekiq. – PHZ.fi-Pharazon Oct 10 '22 at 19:01

0 Answers0