What is the difference between sidekiq perform and perform_async? [closed]
Asked Answered
P

0

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?

Pampa answered 4/1, 2016 at 16:21 Comment(5)
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?Michalmichalak
Yes, I have redis and sidekiq running.Pampa
Check out this SO post #12816726 What is your sidekiq log saying? Is a job getting added to the queue in Redis?Michalmichalak
What is UserMailer? Can you please include the code here.Bide
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.Tussah

© 2022 - 2024 — McMap. All rights reserved.