Class: EventBus::Broker::Rabbit::Queue
- Inherits:
-
Object
- Object
- EventBus::Broker::Rabbit::Queue
- Defined in:
- lib/event_bus/broker/rabbit/queue.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(channel) ⇒ Queue
constructor
A new instance of Queue.
- #subscribe(routing_key, &block) ⇒ Object
Constructor Details
#initialize(channel) ⇒ Queue
Returns a new instance of Queue.
4 5 6 7 |
# File 'lib/event_bus/broker/rabbit/queue.rb', line 4 def initialize(channel) @channel = channel @channel.prefetch(1) end |
Class Method Details
.subscribe(channel, routing_key, &block) ⇒ Object
9 10 11 |
# File 'lib/event_bus/broker/rabbit/queue.rb', line 9 def self.subscribe(channel, routing_key, &block) new(channel).subscribe(routing_key, &block) end |
Instance Method Details
#subscribe(routing_key, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/event_bus/broker/rabbit/queue.rb', line 13 def subscribe(routing_key, &block) name = queue_name(routing_key) channel.queue(name, ) .bind(topic, routing_key: routing_key) .subscribe(manual_ack: true) do |delivery_info, properties, payload| callback(delivery_info, properties, payload, &block) end end |