LoginSignup
5
5

More than 5 years have passed since last update.

Sidekiq を利用したメール送信の遅延処理 (Rails4)

Posted at
  1. redis をインストール.(homebrew 使用)
$ brew install redis```


2. Rails アプリケーションへの組み込み

```Gemfile
gem 'sidekiq'

$ bundle install

  1. redis 起動

$ redis-server /usr/local/etc/redis.conf

  1. sidekiq 起動

$ bundle exec sidekiq

  1. Rails アプリケーションの書き換え sidekiq を インストールすることで, ActionMailer クラスに delay メソッドが追加されている.
# sidekiq 導入前

#UserMailer.hello.deliver# sidekiq 導入後.deliver メソッドは不要になる.

UserMailer.delay.hello```

面倒くさいけど,難しくはないって感じ. 

業務システムでメール送信→画面遷移となっているところでメール送信による遅延が気になっていたので,遅延処理の方法を探していた.
Rails4 の ActiveSupporet に Queue が導入されて,とか,rack_after_reply って gem があってとかも試したけどダメだったよ….

*参考リンク*

[Using Sidekiq to send emails asynchronously](http://blog.remarkablelabs.com/2013/01/using-sidekiq-to-send-emails-asynchronously)

[#366 Sidekiq](http://railscasts.com/episodes/366-sidekiq?language=ja&view=asciicast)



5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5