Using with Rails

Using with Rails 3.x

Two popular AMQP client libraries for Ruby are the bunny and amqp gems. The amqp gem uses the asynchronous EventMachine framework, and so is not a good fit for a Rails application. Thus, use the bunny gem. Add it to your Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.0.10'
gem 'sqlite3'
gem 'bunny'

[...]

After modifying Gemfile, run bundle install to update Gemfile.lock:

$ bundle install
Fetching source index for https://rubygems.org/
Using rake (0.9.2)
[...]
Using rails (3.0.10)
Your bundle is complete! Use `bundle show [gemname]` to see where
a bundled gem is installed.

For a full example of using Bigwig and the Bunny gem with Rails, please check out our example rails application. Once that’s checked out, you’ll be able to deploy that to heroku by running the following shell commands:

 git clone git://github.com/lshift/rabbitmq-service-rails-sample.git
...
$ cd rabbitmq-service-rails-sample
$ heroku apps:create
$ heroku addons:create rabbitmq-bigwig
$ git push heroku master
$ heroku apps:open

The command heroku apps:open should open the sample application in your web-browser. If it can’t figure out how to open a browser on your platform, then visiting the URL previously output by heroku apps:create with any browser will work fine.