Class Aws::Sqs::Queue
In: lib/sqs/right_sqs.rb
Parent: Object

Methods

Attributes

name  [R] 
sqs  [R] 
url  [R] 

Public Class methods

Returns Queue instance by queue name. If the queue does not exist at Amazon SQS and create is true, the method creates it.

 Aws::Sqs::Queue.create(sqs, 'my_awesome_queue') #=> #<Aws::Sqs::Queue:0xb7b626e4 ... >

Creates new Queue instance. Does not create a queue at Amazon.

 queue = Aws::Sqs::Queue.new(sqs, 'my_awesome_queue')

Public Instance methods

Clears queue, deleting only the visible messages. Any message within its visibility timeout will not be deleted, and will re-appear in the queue in the future when the timeout expires.

To delete all messages in a queue and eliminate the chance of any messages re-appearing in the future, it‘s best to delete the queue and re-create it as a new queue. Note that doing this will take at least 60 s since SQS does not allow re-creation of a queue within this interval.

 queue.clear() #=> true

Deletes queue. Any messages in the queue will be permanently lost. Returns true.

NB: Use with caution; severe data loss is possible!

queue.delete(true) #=> true

Retrieves queue attributes. At this moment Amazon supports VisibilityTimeout and ApproximateNumberOfMessages only. If the name of attribute is set, returns its value. Otherwise, returns a hash of attributes.

queue.get_attribute(‘VisibilityTimeout’) #=> {"VisibilityTimeout"=>"45"}

Pops (and deletes) first accessible message from queue. Returns Message instance or nil if the queue is empty.

 queue.pop #=> #<Aws::Sqs::Message:0xb7bf0884 ... >
push(message)

Alias for send_message

Retrieves first accessible message from queue. Returns Message instance or nil it the queue is empty.

 queue.receive #=> #<Aws::Sqs::Message:0xb7bf0884 ... >

Retrieves several messages from queue. Returns an array of Message instances.

 queue.receive_messages(2,10) #=> array of messages

Sends new message to queue. Returns new Message instance that has been sent to queue.

Sets new queue attribute value. Not all attributes may be changed: ApproximateNumberOfMessages (for example) is a read only attribute. Returns a value to be assigned to attribute. Currently, ‘VisibilityTimeout’ is the only settable queue attribute. Attempting to set non-existent attributes generates an indignant exception.

queue.set_attribute(‘VisibilityTimeout’, ‘100’) #=> ‘100’ queue.get_attribute(‘VisibilityTimeout’) #=> ‘100‘

Retrieves queue size.

 queue.size #=> 1

Retrieves VisibilityTimeout value for the queue. Returns new timeout value.

 queue.visibility #=> 30

Sets new VisibilityTimeout for the queue. Returns new timeout value.

 queue.visibility #=> 30
 queue.visibility = 33
 queue.visibility #=> 33

[Validate]