Class: Lapine::Consumer::Connection
- Inherits:
-
Object
- Object
- Lapine::Consumer::Connection
- Defined in:
- lib/lapine/consumer/connection.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#exchange ⇒ Object
readonly
Returns the value of attribute exchange.
Instance Method Summary collapse
- #close! ⇒ Object
-
#initialize(config, topic) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(config, topic) ⇒ Connection
Returns a new instance of Connection.
9 10 11 12 13 |
# File 'lib/lapine/consumer/connection.rb', line 9 def initialize(config, topic) @connection = AMQP.connect(config.connection_properties) @channel = AMQP::Channel.new(connection) @exchange = AMQP::Exchange.new(channel, :topic, topic, durable: true) end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
7 8 9 |
# File 'lib/lapine/consumer/connection.rb', line 7 def channel @channel end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
7 8 9 |
# File 'lib/lapine/consumer/connection.rb', line 7 def connection @connection end |
#exchange ⇒ Object (readonly)
Returns the value of attribute exchange.
7 8 9 |
# File 'lib/lapine/consumer/connection.rb', line 7 def exchange @exchange end |
Instance Method Details
#close! ⇒ Object
15 16 17 |
# File 'lib/lapine/consumer/connection.rb', line 15 def close! @connection.close if @connection.connected? end |