Class: Tackle::Consumer::MainQueue
- Defined in:
- lib/tackle/consumer/main_queue.rb
Instance Attribute Summary
Attributes inherited from Queue
Instance Method Summary collapse
- #bind_to_exchange ⇒ Object
-
#initialize(exchange, connection, logger) ⇒ MainQueue
constructor
A new instance of MainQueue.
- #subscribe(&block) ⇒ Object
Methods inherited from Queue
Constructor Details
#initialize(exchange, connection, logger) ⇒ MainQueue
Returns a new instance of MainQueue.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/tackle/consumer/main_queue.rb', line 5 def initialize(exchange, connection, logger) @exchange = exchange name = @exchange.name = { :durable => true } super(name, , connection, logger) bind_to_exchange end |
Instance Method Details
#bind_to_exchange ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/tackle/consumer/main_queue.rb', line 16 def bind_to_exchange @logger.info("Binding queue '#{name}' to exchange '#{@exchange.name}' with routing_key '#{@exchange.routing_key}'") @amqp_queue.bind(@exchange, :routing_key => @exchange.routing_key) rescue Exception => ex @logger.error "Failed to bind queue to exchange '#{ex}'" raise ex end |
#subscribe(&block) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tackle/consumer/main_queue.rb', line 25 def subscribe(&block) = { :manual_ack => true, :block => true } @amqp_queue.subscribe() do |delivery_info, properties, payload| = Message.new(@connection, @logger, delivery_info, properties, payload) block.call() end end |