[rabbitmq-discuss] How to use AMQP inside Rails ActiveRecord to publish some messages

Eki eqbal.quran at gmail.com
Sat Oct 22 22:09:29 BST 2011

Hi there,

I'm using Rails (3.0.5), Would love to know the best way to publish a
messages from inside my rails application .

To be more specific, lets say, I have a model called Bet, and I wanna
trigger the event after create a record to publish something in the
queue called test for example .

class Bet < ActiveRecord::Base

 after_create :do_some_cool_stuff


 def do_some_cool_stuff
   users = User.all

   users.each do |user|
     MQ.queue("test").publish("some cool message here")


What is the best way inside rails to do that ? where to load AMQP ?
inside model ? inside Environment ? and how to use it more
efficiently ?

Thanks in advance .

More information about the rabbitmq-discuss mailing list