Class: Mimi::Messaging::SQS_SNS::TemporaryQueueConsumer

Inherits:
Object
  • Object
show all
Defined in:
lib/mimi/messaging/sqs_sns/temporary_queue_consumer.rb

Overview

Temporary queue consumer creates a temporary queue and attaches to it. The queue will be deleted on consumer shutdown.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter, queue_name, &block) ⇒ TemporaryQueueConsumer

Returns a new instance of TemporaryQueueConsumer.



14
15
16
17
18
# File 'lib/mimi/messaging/sqs_sns/temporary_queue_consumer.rb', line 14

def initialize(adapter, queue_name, &block)
  @adapter = adapter
  @queue_url = adapter.find_or_create_queue(queue_name)
  @consumer = Consumer.new(adapter, @queue_url, &block)
end

Instance Attribute Details

#queue_urlObject (readonly)

Returns the value of attribute queue_url.



12
13
14
# File 'lib/mimi/messaging/sqs_sns/temporary_queue_consumer.rb', line 12

def queue_url
  @queue_url
end

Instance Method Details

#stopObject



20
21
22
23
24
25
# File 'lib/mimi/messaging/sqs_sns/temporary_queue_consumer.rb', line 20

def stop
  @consumer.stop
  @adapter.delete_queue(queue_url)
rescue StandardError => e
  raise Mimi::Messaging::Error, "Failed to stop temporary queue consumer: #{e}"
end