Class: JackRabbit::Subscription
- Inherits:
-
Object
- Object
- JackRabbit::Subscription
- Includes:
- Logging
- Defined in:
- lib/jack_rabbit/subscription.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ blocking: false }
Constants included from Logging
Instance Method Summary collapse
- #declare ⇒ Object
-
#initialize(channel, exchange, key, queue, options, &block) ⇒ Subscription
constructor
A new instance of Subscription.
Methods included from Logging
Constructor Details
#initialize(channel, exchange, key, queue, options, &block) ⇒ Subscription
Returns a new instance of Subscription.
10 11 12 13 14 |
# File 'lib/jack_rabbit/subscription.rb', line 10 def initialize(channel, exchange, key, queue, , &block) @channel = channel @exchange, @key, @queue, @options = exchange, key, queue, @block = block end |
Instance Method Details
#declare ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/jack_rabbit/subscription.rb', line 16 def declare exchange = @channel.create_exchange(@exchange, @options) queue = @channel.create_queue(@queue, @options) queue.bind(exchange, { routing_key: @key }) @subscription = queue.subscribe(DEFAULT_OPTIONS.merge(@options)) do |, | @block.call(MessageHeader.new(), ) end end |