I created a publicly available gem estorm-message-processor to simplify the creation of AMQP scripts to process messages. Full details are on estorm-message-processor source. This gem simplifies the development of scripts which either process messages for ever or process messages on demand. It uses a call back processor concept so that you can send many different types of commands to the message processor. This code has been live in a production application for over two years and handled millions of messages.

Setup delegate processor

This is the callback processor in the consumer. Just define your methods in your script with the name of procedure like delegate_XXXXX. Send the queue a message with a hash and any transport variables you want to send. {'command'=>'sendtemplates', 'promotion'=>}. See the how command is linked to the name of the delegate? Code:

class EstormMessageProcessor::Consumer
def delegate_sendtemplates(cmdhash)
data.each { |entry| 
cc=CustomerContact.create_and_send_template(entry['email'],entry,p.configuration_setting,p) if entry!=nil and entry['email']!=nil           }

Start the Message Processor


config={:url => AMQPURL,:connecturlflag=> Rails.env.production? ,:queuename => CONTACT_MESSAGE, :blocking => true, :consumer_name => "test consumer"}   
mp =
mp.start(config)  # THIS MAY NEED TO BE IN a THREAD
rescue Exception => ex