module RubyRabbitmqJanus::Process::Concurrencies::ThreadRunnerConcern
Module injected in Concurrencies
classes.
Manage threads for public/admin queue to rabbitmq.
:reek: ModuleInitialize
Public Class Methods
new()
click to toggle source
Initialize an process (event/event_admin) and configure the life cycle to thread.
Calls superclass method
# File lib/rrj/process/thread_runner_concern.rb, line 19 def initialize super @thread = Thread.new { initialize_thread } end
Public Instance Methods
run(&block)
click to toggle source
Create a thread for execute a block code in a thread. This code is outside to `RRJ` gem so is very important to be sure this code execution is not fail.
@param [Proc] block Block code for execute action when queue
standard 'from-janus' receive a message.This block is sending to publisher created for this thread.
@return [Thread] It's a thread who listen queue and execute action
# File lib/rrj/process/thread_runner_concern.rb, line 33 def run(&block) raise_nil_block unless block @thread.join Thread.new do loop do @thread.thread_variable_get(name_publisher) .listen_events(&block) rescue StandardError => exception ::Log.warn exception end end end
transaction_running()
click to toggle source
# File lib/rrj/process/thread_runner_concern.rb, line 49 def transaction_running @thread.thread_variable_set(name_publisher, publisher) end