lib/alephant/publisher/queue/sqs_helper/queue.rb in alephant-publisher-queue-2.0.0 vs lib/alephant/publisher/queue/sqs_helper/queue.rb in alephant-publisher-queue-2.0.1

- old
+ new

@@ -11,31 +11,39 @@ include Logger attr_reader :queue, :timeout, :wait_time, :archiver - def initialize(queue, archiver = nil, timeout = VISABILITY_TIMEOUT, wait_time = WAIT_TIME) + def initialize( + queue, + archiver = nil, + timeout = VISABILITY_TIMEOUT, + wait_time = WAIT_TIME + ) @queue = queue @archiver = archiver @timeout = timeout @wait_time = wait_time + log_queue_creation queue.url, archiver, timeout + end + def message + receive.tap { |m| process(m) unless m.nil? } + end + + private + + def log_queue_creation(queue_url, archiver, timeout) logger.info( "event" => "QueueConfigured", - "queueUrl" => queue.url, + "queueUrl" => queue_url, "archiver" => archiver, "timeout" => timeout, "method" => "#{self.class}#initialize" ) end - def message - receive.tap { |m| process(m) unless m.nil? } - end - - private - def process(m) logger.metric "MessagesReceived" logger.info( "event" => "QueueMessageReceived", "messageId" => m.id, @@ -56,13 +64,13 @@ "method" => "#{self.class}#archive" ) end def receive - queue.receive_message({ + queue.receive_message( :visibility_timeout => timeout, :wait_time_seconds => wait_time - }) + ) end end end end end