Method: Msgr::Binding#initialize

Defined in:
lib/msgr/binding.rb

#initialize(connection, route, dispatcher) ⇒ Binding

Returns a new instance of Binding.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/msgr/binding.rb', line 16

def initialize(connection, route, dispatcher)
  @connection = connection
  @channel    = connection.channel(prefetch: route.prefetch)
  @route      = route
  @dispatcher = dispatcher
  @queue      = @channel.queue(route.name)

  route.keys.each do |key|
    log(:debug) { "Bind #{key} to #{queue.name}." }

    queue.bind @channel.exchange, routing_key: key
  end

  subscribe
end