Class: Ragnar::SimpleQueue
- Inherits:
-
Object
- Object
- Ragnar::SimpleQueue
- Defined in:
- lib/ragnar/simple_queue.rb
Overview
Simple publishing via a wrapper around bunny
Class Method Summary collapse
- .options ⇒ Object
-
.publish(message, route, exchange, opts = {}) ⇒ Object
Note this method does not bind a queue to an exchange, therefore it’s required that the queue/exchange are already bound before calling this method.
Class Method Details
.options ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/ragnar/simple_queue.rb', line 8 def self. @options ||= { :host => Ragnar::Config.host, :port => Ragnar::Config.port, :logging => false } end |
.publish(message, route, exchange, opts = {}) ⇒ Object
Note this method does not bind a queue to an exchange, therefore it’s required that the queue/exchange are already bound before calling this method
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ragnar/simple_queue.rb', line 19 def self.publish(, route, exchange, opts={}) # delete the exchange type from the options or set it to topic exchange_type = opts.delete(:exchange_type) { 'topic' } @publish_mutex ||= ::Mutex.new @publish_mutex.synchronize do ::Bunny.run() do |bunny| exchange = bunny.exchange(exchange, :type => exchange_type) exchange.publish(, opts.merge(:key => route)) end end end |