Class: Propono::QueueListener

Inherits:
Object
  • Object
show all
Defined in:
lib/propono/services/queue_listener.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aws_client, propono_config, topic_name, options = {}, &message_processor) ⇒ QueueListener

Returns a new instance of QueueListener.



13
14
15
16
17
18
19
# File 'lib/propono/services/queue_listener.rb', line 13

def initialize(aws_client, propono_config, topic_name, options = {}, &message_processor)
  @aws_client = aws_client
  @propono_config = propono_config
  @topic_name = topic_name
  @message_processor = message_processor
  @visibility_timeout = options[:visibility_timeout] || nil
end

Instance Attribute Details

#aws_clientObject (readonly)

Returns the value of attribute aws_client.



12
13
14
# File 'lib/propono/services/queue_listener.rb', line 12

def aws_client
  @aws_client
end

#message_processorObject (readonly)

Returns the value of attribute message_processor.



12
13
14
# File 'lib/propono/services/queue_listener.rb', line 12

def message_processor
  @message_processor
end

#propono_configObject (readonly)

Returns the value of attribute propono_config.



12
13
14
# File 'lib/propono/services/queue_listener.rb', line 12

def propono_config
  @propono_config
end

#topic_nameObject (readonly)

Returns the value of attribute topic_name.



12
13
14
# File 'lib/propono/services/queue_listener.rb', line 12

def topic_name
  @topic_name
end

#visibility_timeoutObject (readonly)

Returns the value of attribute visibility_timeout.



12
13
14
# File 'lib/propono/services/queue_listener.rb', line 12

def visibility_timeout
  @visibility_timeout
end

Class Method Details

.drain(*args, &message_processor) ⇒ Object



8
9
10
# File 'lib/propono/services/queue_listener.rb', line 8

def self.drain(*args, &message_processor)
  new(*args, &message_processor).drain
end

.listen(*args, &message_processor) ⇒ Object



4
5
6
# File 'lib/propono/services/queue_listener.rb', line 4

def self.listen(*args, &message_processor)
  new(*args, &message_processor).listen
end

Instance Method Details

#drainObject

Raises:



28
29
30
31
32
# File 'lib/propono/services/queue_listener.rb', line 28

def drain
  raise ProponoError.new("topic_name is nil") unless topic_name
  true while read_messages_from_queue(main_queue, 10, long_poll: false)
  true while read_messages_from_queue(slow_queue, 10, long_poll: false) if propono_config.slow_queue_enabled
end

#listenObject

Raises:



21
22
23
24
25
26
# File 'lib/propono/services/queue_listener.rb', line 21

def listen
  raise ProponoError.new("topic_name is nil") unless topic_name
  loop do
    read_messages
  end
end