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
10 11 12 13 14 |
# File 'lib/rrj/rabbit/connect.rb', line 10 def initialize @rabbit = Bunny.new(.merge!(option_log_rabbit)) rescue raise Errors::Rabbit::Connect::Initialize end |
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 raise Errors::Rabbit::Channel 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 raise Errors::Rabbit::Close end |
#start ⇒ Object
Openning a connection with Rabbitmq
34 35 36 37 38 |
# File 'lib/rrj/rabbit/connect.rb', line 34 def start @rabbit.start rescue raise Errors::Rabbit::Start 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 raise Errors::Rabbit::Connect::TransactionLong 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 raise Errors::Rabbit::Connect::TransactionShort end |