Class: Tackle::Consumer::Exchange
- Inherits:
-
Object
- Object
- Tackle::Consumer::Exchange
- Defined in:
- lib/tackle/consumer/exchange.rb
Instance Attribute Summary collapse
-
#routing_key ⇒ Object
readonly
Returns the value of attribute routing_key.
Instance Method Summary collapse
- #bind_to_exchange(remote_exchange_name) ⇒ Object
-
#initialize(service_name, routing_key, connection, logger) ⇒ Exchange
constructor
A new instance of Exchange.
- #name ⇒ Object
Constructor Details
#initialize(service_name, routing_key, connection, logger) ⇒ Exchange
Returns a new instance of Exchange.
7 8 9 10 11 12 13 14 15 |
# File 'lib/tackle/consumer/exchange.rb', line 7 def initialize(service_name, routing_key, connection, logger) @service_name = service_name @routing_key = routing_key @connection = connection @logger = logger @logger.info("Creating local exchange '#{name}'") @amqp_exchange = @connection.channel.direct(name, :durable => true) end |
Instance Attribute Details
#routing_key ⇒ Object (readonly)
Returns the value of attribute routing_key.
5 6 7 |
# File 'lib/tackle/consumer/exchange.rb', line 5 def routing_key @routing_key end |
Instance Method Details
#bind_to_exchange(remote_exchange_name) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tackle/consumer/exchange.rb', line 21 def bind_to_exchange(remote_exchange_name) @logger.info("Creating remote exchange '#{remote_exchange_name}'") @connection.channel.direct(remote_exchange_name, :durable => true) @logger.info("Binding exchange '#{name}' to exchange '#{remote_exchange_name}'") @amqp_exchange.bind(remote_exchange_name, :routing_key => routing_key) rescue Exception => ex @logger.error "Binding to remote exchange failed #{ex}" raise ex end |
#name ⇒ Object
17 18 19 |
# File 'lib/tackle/consumer/exchange.rb', line 17 def name "#{@service_name}.#{@routing_key}" end |