Skip to content

fast-programmer/outboxer

Repository files navigation

📤 Outboxer

Gem Version Coverage Status Join our Discord

Outboxer is a battle-tested implementation of the transactional outbox pattern for Ruby on Rails applications.

Increase reliability, resilience, fault tolerance and scalability without the fear of lost messages, data corruption, or sleepless nights.

Outboxer helps you quickly migrate to eventually consistent, event driven architecture.

🚀 Quickstart

1. Install gem

bundle add outboxer
bundle install

2. Generate schema migrations, publisher script and tests

bin/rails g outboxer:install

3. Migrate database

bin/rails db:migrate

4. Generate messageable schema and model

bin/rails generate model Event
bin/rails db:migrate

5. Queue message after messageable is created

# app/models/event.rb

class Event < ApplicationRecord
  after_create { Outboxer::Message.queue(messageable: self) }
end

6. Publish messages

# bin/outboxer_publisher

Outboxer::Publisher.publish_messages do |messages|
  # TODO: publish messages here

  messages.each do |message|
    logger.info "Outboxer published message " \
      "id=#{message[:id]} " \
      "messageable_type=#{message[:messageable_type]} " \
      "messageable_id=#{message[:messageable_id]} "
  end
end

🧪 Testing

The generated spec/bin/outboxer_publisher adds end to end queue and publish message test coverage.

📈 Monitoring

Monitor using the built-in web UI:

Publishers

Screenshot 2025-04-30 at 6 25 06 pm

Messages

Screenshot 2025-04-30 at 6 25 37 pm

Rails

# config/routes.rb

require 'outboxer/web'

mount Outboxer::Web, at: '/outboxer'

Rack

# config.ru

require 'outboxer/web'

map '/outboxer' { run Outboxer::Web }

🤝 Contributing

All contributions are welcome!

⚖️ License

Open-sourced under LGPL v3.0.

🏁 Why Outboxer?

  • Production-hardened
  • Lightweight and easy to integrate
  • Scales to millions of messages
  • Built to survive crashes, outages, and scale