Class: RubyRabbitmqJanus::Rabbit::Connect
- Inherits:
-
Object
- Object
- RubyRabbitmqJanus::Rabbit::Connect
- Defined in:
- lib/rrj/rabbit/connect.rb
Overview
Class for manage connection with RabbitMQ
Instance Method Summary collapse
-
#channel ⇒ Object
Create an channel.
-
#close ⇒ Object
Close connection to server RabbitMQ.
-
#initialize ⇒ Connect
constructor
Initialize connection to server RabbitMQ.
-
#start ⇒ Object
Opening a connection with RabbitMQ.
-
#transaction_long ⇒ Object
Create an transaction with rabbitmq and not close.
-
#transaction_short ⇒ Object
Create an transaction with rabbitmq and close after response is received.
Constructor Details
Instance Method Details
#channel ⇒ Object
Create an channel
48 49 50 51 52 |
# File 'lib/rrj/rabbit/connect.rb', line 48 def channel @rabbit.create_channel rescue => exception raise Errors::Rabbit::Connect::Channel, exception end |
#close ⇒ Object
Close connection to server RabbitMQ
41 42 43 44 45 |
# File 'lib/rrj/rabbit/connect.rb', line 41 def close @rabbit.close rescue => exception raise Errors::Rabbit::Connect::Close, exception end |
#start ⇒ Object
Opening a connection with RabbitMQ
34 35 36 37 38 |
# File 'lib/rrj/rabbit/connect.rb', line 34 def start @rabbit.start rescue => exception raise Errors::Rabbit::Connect::Start, exception end |
#transaction_long ⇒ Object
Create an transaction with rabbitmq and not close
26 27 28 29 30 31 |
# File 'lib/rrj/rabbit/connect.rb', line 26 def transaction_long start yield rescue => exception raise Errors::Rabbit::Connect::TransactionLong, exception end |
#transaction_short ⇒ Object
Create an transaction with rabbitmq and close after response is received
17 18 19 20 21 22 23 |
# File 'lib/rrj/rabbit/connect.rb', line 17 def transaction_short response = transaction_long { yield } close response rescue => exception raise Errors::Rabbit::Connect::TransactionShort, exception end |