lib/rrj/process/event.rb in ruby_rabbitmq_janus-3.0.0.pre.352 vs lib/rrj/process/event.rb in ruby_rabbitmq_janus-3.0.0.pre.354

- old
+ new

@@ -10,43 +10,23 @@ # Listen standard queue and sending a block code to thread listen. # The default queue is configured in config file. # # @see file:/config/default.md For more information to config file used. class Event < Concurrency - NAME_VAR = :publish + include RubyRabbitmqJanus::Process::Concurrencies::ThreadRunnerConcern - def initialize - super - @thread = Thread.new { initialize_thread } + private + + def raise_nil_block + raise RubyRabbitmqJanus::Errors::Process::Event::Run end - # Create a thread for execute a block code in a thread - # - # @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 - def run(&block) - raise RubyRabbitmqJanus::Errors::Process::Event::Run \ - unless block_given? - - @thread.join - Thread.new do - loop do - @thread.thread_variable_get(NAME_VAR).listen_events(&block) - end - end + def name_publisher + :publish end - private - def publisher Rabbit::Listener::From.new(rabbit) - end - - def transaction_running - @thread.thread_variable_set(NAME_VAR, publisher) end end end end end