mongodb + mailqueue + rails? Yes! – KRUG - 11th September 2013



mongodb + mailqueue + rails? Yes! – KRUG - 11th September 2013

0 2


krug-mongo-mailqueue-rails


On Github knapo / krug-mongo-mailqueue-rails

mongodb + mailqueue + rails? Yes!

KRUG - 11th September 2013

Krzysztof Knapik @knapo github.com/knapo

about me

Tech Lead @ Lunar Logic

Ruby & JS consultant @ infakt

@knapo

github.com/knapo

asynchronus or not?

if yes...

how?

redis + resque_mailer?

NO.

  • no VM & swapping, good for small and not very important data.
  • requires implementation, non-OOTB:

delayed_job?

NO.

  • queue in SQL - possible.............
  • requires implementation, non-OOTB:

custom RabbitMQ solution?

MAYBE...

  • promising, but over complicated

https://blog.serverdensity.com/replacing-rabbitmq-with-mongodb

why mongo?

  • swapping
  • journaling
  • atomic findAndModify operation
  • scalability

mongo_mailer

github.com/infakt/mongo_mailer

mongo_mailer components

  • rails plugin providing ActionMailer delivery method, generators & capistrano recipies
  • (standalone) worker

rails plugin

# Gemfile
gem 'mongo_mailer', require: 'mongo_mailer/rails'
# environment file
config.action_mailer.delivery_method :mongo_queue
$ bundle exec rails generate mongo_mailer		
#=> config/mongo_mailer.yml.example
# config/deploy.rb
require 'mongo_mailer/capistrano'
$ cap mongo_mailer:start|stop|restart

(standalone) worker

# rails app
$ bundle exec mongo_mailer start|stop|restart
# independent app
$ bundle exec worker start|stop|restart

base and emergency delivery methods

config/mongo_mailer.yml

  base_delivery_method: smtp
  base_delivery_settings:
    user_name: "username"
    password: "apikey"
    domain: "example.com"
    address: "smtp1.example.com"
    port: 587
    authentication: plain
  emergency_delivery_method: smtp
  emergency_delivery_settings:
    user_name: "username"
    password: "apikey"
    domain: "example.com"
    address: "smtp2.example.com"
    port: 587
    authentication: plain
	

questions?

thank you!

slides: http://knapo.github.io/krug-mongo-mailqueue-rails/