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
Openning 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
#initialize ⇒ Connect
Initialize connection to server RabbitMQ
12 13 14 15 16 |
# File 'lib/rrj/rabbit/connect.rb', line 12 def initialize @rabbit = Bunny.new(.merge!(option_log_rabbit)) rescue => error raise Errors::Rabbit::Connect::Initialize, error end |
Instance Method Details
#channel ⇒ Object
Create an channel
50 51 52 53 54 |
# File 'lib/rrj/rabbit/connect.rb', line 50 def channel @rabbit.create_channel rescue => error raise Errors::Rabbit::Connect::Channel, error end |
#close ⇒ Object
Close connection to server RabbitMQ
43 44 45 46 47 |
# File 'lib/rrj/rabbit/connect.rb', line 43 def close @rabbit.close rescue => error raise Errors::Rabbit::Connect::Close, error end |
#start ⇒ Object
Openning a connection with Rabbitmq
36 37 38 39 40 |
# File 'lib/rrj/rabbit/connect.rb', line 36 def start @rabbit.start rescue => error raise Errors::Rabbit::Connect::Start, error end |
#transaction_long ⇒ Object
Create an transaction with rabbitmq and not close
28 29 30 31 32 33 |
# File 'lib/rrj/rabbit/connect.rb', line 28 def transaction_long start yield rescue => error raise Errors::Rabbit::Connect::TransactionLong, error end |
#transaction_short ⇒ Object
Create an transaction with rabbitmq and close after response is received
19 20 21 22 23 24 25 |
# File 'lib/rrj/rabbit/connect.rb', line 19 def transaction_short response = transaction_long { yield } close response rescue => error raise Errors::Rabbit::Connect::TransactionShort, error end |