Class: RubyRabbitmqJanus::Process::Concurrencies::EventAdmin

Inherits:
Concurrency
  • Object
show all
Defined in:
lib/rrj/process/event_admin.rb

Overview

# Listen admin queue to all Janus instance

Listen admin queue and sending a block code to thread listen. The default queue is configured in config file.

Constant Summary collapse

NAME_VAR =
:publish_adm

Instance Method Summary collapse

Constructor Details

#initializeEventAdmin

Returns a new instance of EventAdmin.



17
18
19
20
21
22
# File 'lib/rrj/process/event_admin.rb', line 17

def initialize
  super
  @thread = Thread.new { initialize_thread }
rescue
  raise Errors::Process::Event::Initializer
end

Instance Method Details

#run(&block) ⇒ Thread

Create a thread for execute a block code in a thread

Parameters:

  • block (Proc)

    Block code for execute action when queue standard ‘from-janus’ receive a message.This block is sending to publisher created for this thread.

Returns:

  • (Thread)

    It’s a thread who listen queue and execute action



31
32
33
34
35
36
37
38
39
40
# File 'lib/rrj/process/event_admin.rb', line 31

def run(&block)
  @thread.join
  Thread.new do
    loop do
      @thread.thread_variable_get(NAME_VAR).listen_events(&block)
    end
  end
rescue
  raise Errors::Process::Event::Run
end