Difference between Action Job/Mailer's `deliver_now` and `deliver_later`

前端 未结 2 1808
南方客
南方客 2021-02-12 07:24

The common pattern for interfacing with ActionJob in Rails is to set up a Job with a perform() method that gets called asynchronously via perform

2条回答
  •  孤独总比滥情好
    2021-02-12 08:01

    As you say in your question, deliver_now does not use ActiveJob.

    Basically, deliver_later is asynchronous. When you use this method, the email is not send at the moment, but rather is pushed in a job's queue. If the job is not running, the email will not be sent. deliver_now will send the email at the moment, no matter what is the job's state. Here you can see the documentation for deliver methods.

    According to your second question, perform_now will process the job immediately without sending to the queue. perform_later, however, will add the job to the queue, and as soon the job's queue is free, will perform the job. Here you can see the documentation for perform methods.

提交回复
热议问题