Skip to content
Kenneth Kalmer edited this page Jun 5, 2011 · 1 revision

The AMQP generator creates a simple daemon that leverages the amqp gem to process inbound messages. The daemon will setup the connection and provide a block for where you can setup your AMQP client.

Dependencies

The AMQP gem currently provides two versions supported by daemon-kit, and you'll need to pick one based on your production environment.

The generated Gemfile has both options, preferring 1.9 over 1.8.

Ruby 1.9

It is recommended that you use version 0.8.0.rc12 or later. The 0.8 series is stable and recommended for usage, but does not current work on Ruby 1.8.7 due to a bug in Ruby itself.

Ruby 1.8

It is recommended that you use version 0.7.1 until the said bug is fixed in Ruby 1.8.7

Configuration

defaults: &defaults
  user: guest
  pass: guest
  host: localhost
  vhost: /

development:
  <<: *defaults

test:
  <<: *defaults

production:
  <<: *defaults

These values will be used to configure the ampq gem, any values omitted will let the gem use it's own defaults.

The configuration specifies the following keys:

  • user - Username for the broker
  • pass - Password for the broker
  • host - Hostname where the broker is running
  • vhost - Vhost to connect to
  • port - Port where the broker is running
  • ssl - Use ssl or not
  • timeout - Timeout

Usage

A template is provided in libexec/<name>\_daemon.rb. The DaemonKit::AMQP provides the same context as AMQP.run, and handles the connection logic for you.

Clone this wiki locally