An example Ruby on Rails 2.3 application that uses Ruby AMQP gem with Unicorn
Ruby JavaScript
Permalink
Failed to load latest commit information.
app
config Initial commit May 25, 2011
db Initial commit May 25, 2011
doc Initial commit May 25, 2011
public Initial commit May 25, 2011
script Initial commit May 25, 2011
test Initial commit May 25, 2011
.gitignore Initial commit May 25, 2011
Gemfile Initial commit May 25, 2011
Gemfile.lock Initial commit May 25, 2011
LICENSE Put together a very short README to explain what is going on here May 25, 2011
README.md Edited README.md via GitHub Jun 1, 2011
Rakefile Initial commit May 25, 2011

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.