[rabbitmq-discuss] Creating Queues and Exchanges on the Fly

Ben Hood 0x6e6562 at gmail.com
Thu Sep 4 23:06:08 BST 2008


Preston,

On Thu, Sep 4, 2008 at 10:02 PM, Preston Marshall
<preston at synergy-solutions.biz> wrote:
> Here is my code for what I'm describing, do me a favor and see if it looks
> right:
>
> amq.queue('all').bind(amq.topic, :key => "events").subscribe{ |info, object|
>  puts "Recieved All Event Message"
>  unless info.headers[:sender].to_s == info.headers[:sender].to_s
>    doc = REXML::Document.new object.to_s
>    EventMessage.create :name => doc.elements['//headline'].text.to_s,
> :home_county => info.headers[:sender].to_s, :acknowledged => false,
> :external => true, :event_type_id => doc.elements['//typeid'].text.to_i,
> :status_id => doc.elements['//statusid'].text.to_i, :scope =>
> "#{doc.elements['//scope'].text}", :urgency_id =>
> doc.elements['//urgencyid'].text.to_i, :severity_id =>
> doc.elements['//severityid'].text.to_i, :certainty_id =>
> doc.elements['//certaintyid'].text.to_i, :uuid =>
> doc.elements['//identifier'].text.to_s
>    #Here comes the posts queue
>    amq.queue("#{doc.elements['//identifier'].text.to_s}").bind(amq.topic,
> :key =>
> "#{doc.elements['//identifier'].text.to_s}.posts").subscribe{|postinfo,
> postobject|
>      puts "Setup UUID Queue for UUID:
> #{doc.elements['//identifier'].text.to_s}"
>      puts postinfo.to_s
>      puts postobject.to_s
>      }
>  end

And I thought Ruby was supposed to be a nice concise syntax :-)

I'm sorry, I can't tell what's going on here - maybe Aman can shed
some light on the topic?

Ben




More information about the rabbitmq-discuss mailing list