Class: RubyRabbitmqJanus::Janus::Transactions::Handle
- Inherits:
-
Transaction
- Object
- Transaction
- RubyRabbitmqJanus::Janus::Transactions::Handle
- Defined in:
- lib/rrj/janus/transactions/handle.rb
Overview
This class work with janus and send a series of message
Instance Method Summary collapse
-
#connect { ... } ⇒ Fixnum
Opening a long transaction with rabbitmq and is ending closing transaction, so delete exclusive queue.
-
#detach ⇒ Object
Send a message detach.
-
#detach_for_deleting ⇒ Object
Send a message detach and disable session for deleting in Janus Instance.
-
#initialize(exclusive, session, handle = 0, instance = 1) ⇒ Handle
constructor
Initialize a transaction with handle.
-
#publish_message(type, options = {}) ⇒ Janus::Responses::Standard
Publish an message in handle.
Constructor Details
#initialize(exclusive, session, handle = 0, instance = 1) ⇒ Handle
Initialize a transaction with handle
16 17 18 19 20 21 |
# File 'lib/rrj/janus/transactions/handle.rb', line 16 def initialize(exclusive, session, handle = 0, instance = 1) super(session) @exclusive = exclusive @handle = handle @instance = instance end |
Instance Method Details
#connect { ... } ⇒ Fixnum
Opening a long transaction with rabbitmq and is ending closing transaction, so delete exclusive queue
29 30 31 32 33 34 35 36 |
# File 'lib/rrj/janus/transactions/handle.rb', line 29 def connect rabbit.transaction_short do choose_queue create_handle if @handle.eql?(0) yield end handle end |
#detach ⇒ Object
Send a message detach
51 52 53 54 55 56 |
# File 'lib/rrj/janus/transactions/handle.rb', line 51 def detach = opts.merge('instance' => @instance) ::Log.debug "Detach handle #{}" publisher.publish(Janus::Messages::Standard.new('base::detach', )) end |
#detach_for_deleting ⇒ Object
Send a message detach and disable session for deleting in Janus Instance
60 61 62 63 |
# File 'lib/rrj/janus/transactions/handle.rb', line 60 def detach_for_deleting detach Models::JanusInstance.disable(opts['session_id']) end |
#publish_message(type, options = {}) ⇒ Janus::Responses::Standard
Publish an message in handle
44 45 46 47 48 |
# File 'lib/rrj/janus/transactions/handle.rb', line 44 def (type, = {}) msg = Janus::Messages::Standard.new(type, .merge(opts)) response = read_response(publisher.publish(msg)) Janus::Responses::Standard.new(response) end |