Class: MessageQueue::Adapters::Bunny::Connection
- Inherits:
-
Connection
- Object
- Connection
- MessageQueue::Adapters::Bunny::Connection
- Defined in:
- lib/message_queue/adapters/bunny/connection.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Attributes inherited from Connection
Instance Method Summary collapse
-
#connect ⇒ Object
Public: Connect to RabbitMQ.
-
#connected? ⇒ Boolean
Public: Check if it’s connected to the message queue.
-
#disconnect ⇒ Object
Public: Disconnect from RabbitMQ.
- #new_consumer(options) ⇒ Object
- #new_producer(options) ⇒ Object
Methods inherited from Connection
Methods included from Logging
#logger, logger, logger=, setup_logger
Constructor Details
This class inherits a constructor from MessageQueue::Connection
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
2 3 4 |
# File 'lib/message_queue/adapters/bunny/connection.rb', line 2 def connection @connection end |
Instance Method Details
#connect ⇒ Object
Public: Connect to RabbitMQ
Returns the Bunny instance
7 8 9 10 11 12 13 14 |
# File 'lib/message_queue/adapters/bunny/connection.rb', line 7 def connect @connection ||= begin super bunny = ::Bunny.new(bunny_settings) bunny.start bunny end end |
#connected? ⇒ Boolean
Public: Check if it’s connected to the message queue
Returns true if it’s connected
30 31 32 |
# File 'lib/message_queue/adapters/bunny/connection.rb', line 30 def connected? @connection.open? if @connection end |
#disconnect ⇒ Object
Public: Disconnect from RabbitMQ
Returns nothing
19 20 21 22 23 24 25 |
# File 'lib/message_queue/adapters/bunny/connection.rb', line 19 def disconnect if @connection super @connection.close if @connection.open? @connection = nil end end |
#new_consumer(options) ⇒ Object
40 41 42 43 44 |
# File 'lib/message_queue/adapters/bunny/connection.rb', line 40 def new_consumer() raise "No connection to RabbitMQ" unless connection Consumer.new(self, ) end |
#new_producer(options) ⇒ Object
34 35 36 37 38 |
# File 'lib/message_queue/adapters/bunny/connection.rb', line 34 def new_producer() raise "No connection to RabbitMQ" unless connection Producer.new(self, ) end |