Class: Warren::Subscription
- Inherits:
-
Object
- Object
- Warren::Subscription
- Extended by:
- Forwardable
- Defined in:
- lib/warren/subscription.rb
Overview
Configures and wraps up subscriptions on a Bunny Channel/Queue
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
Instance Method Summary collapse
-
#activate! ⇒ Object
Ensures the queues and channels are set up to receive messages keys: additional routing_keys to bind.
-
#initialize(channel:, config:) ⇒ Subscription
constructor
Great a new subscription.
-
#subscribe(consumer_tag) {|delivery_info, properties, payload| ... } ⇒ Bunny::Consumer
Subscribes to the given queue.
Constructor Details
#initialize(channel:, config:) ⇒ Subscription
Great a new subscription. Handles queue creation, binding and attaching consumers to the queues
17 18 19 20 21 22 |
# File 'lib/warren/subscription.rb', line 17 def initialize(channel:, config:) @channel = channel @queue_name = config&.fetch('name') @queue_options = config&.fetch('options') @bindings = config&.fetch('bindings') end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
8 9 10 |
# File 'lib/warren/subscription.rb', line 8 def channel @channel end |
Instance Method Details
#activate! ⇒ Object
Ensures the queues and channels are set up to receive messages keys: additional routing_keys to bind
44 45 46 |
# File 'lib/warren/subscription.rb', line 44 def activate! establish_bindings! end |
#subscribe(consumer_tag) {|delivery_info, properties, payload| ... } ⇒ Bunny::Consumer
Subscribes to the given queue
37 38 39 40 |
# File 'lib/warren/subscription.rb', line 37 def subscribe(consumer_tag, &block) channel.prefetch(10) queue.subscribe(manual_ack: true, block: false, consumer_tag: consumer_tag, durable: true, &block) end |