Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An example Ruby on Rails 2.3 application that uses Ruby AMQP gem with Unicorn

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 config
Octocat-spinner-32 db
Octocat-spinner-32 doc
Octocat-spinner-32 public
Octocat-spinner-32 script
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
README.md

An example Ruby on Rails 2.3 application that uses Ruby AMQP gem with Unicorn

This app demonstrates how you can integrate Ruby amqp gem into a Ruby on Rails application that runs on Unicorn.

Getting Started

gem install bundler

and then

bundle install

finally,

unicorn_rails --port=3000 -c config/unicorn/development.rb

What does it do?

On application boot, Unicorn forks 1 worker and that worker starts EventMachine event loop in a separate thread and then establishes connection to AMQP broker. The key here is to not start EventMachine reactor before the fork: due to a known EventMachine issue, this will result in a reactor in limbo (because forking has side effects on open file descriptors). Restarting it is possible but not without hacks and requires some knowledge about EventMachine internals.

Once connection is established, we publish a bunch of messages using default direct exchange.

License

Apache Public License 2.0.

See LICESE file in the repository root.

Something went wrong with that request. Please try again.