Class | RightAws::Sqs::Queue |
In: |
lib/sqs/right_sqs.rb
|
Parent: | Object |
name | [R] | |
sqs | [R] | |
url | [R] |
Clears queue. Deletes only the visible messages unless force is true.
queue.clear(true) #=> true
P.S. when force==true the queue deletes then creates again. This is the quickest method to clear a big queue or a queue with ‘locked’ messages. All queue attributes are restored. But there is no way to restore grantees’ permissions to this queue. If you have no grantees except ‘root’ then you have no problems. Otherwise, it‘s better to use queue.clear(false).
PS This function is no longer supported. Amazon has changed the SQS semantics to require at least 60 seconds between queue deletion and creation. Hence this method will fail with an exception.
Deletes queue. Queue must be empty or force must be set to true. Returns true.
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’) #=> ‘100‘
Retrieves a list of grantees. Returns an array of Grantee instances if the grantee_email_address is unset. Otherwise returns a Grantee instance that points to grantee_email_address or nil.
grantees = queue.grantees #=> [#<RightAws::Sqs::Grantee:0xb7bf0888 ... >, ...] ... grantee = queue.grantees('cool_guy@email.address') #=> nil | #<RightAws::Sqs::Grantee:0xb7bf0888 ... >
Pops (and deletes) first accessible message from queue. Returns Message instance or nil it the queue is empty.
queue.pop #=> #<RightAws::Sqs::Message:0xb7bf0884 ... >
Retrieves first accessible message from queue. Returns Message instance or nil it the queue is empty.
queue.receive #=> #<RightAws::Sqs::Message:0xb7bf0884 ... >
Retrieves several messages from queue. Returns an array of Message instances.
queue.receive_messages(2,10) #=> array of messages
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.
queue.set_attribute(‘VisibilityTimeout’, ‘100’) #=> ‘100’ queue.get_attribute(‘VisibilityTimeout’) #=> ‘100‘
Retrieves VisibilityTimeout value for the queue. Returns new timeout value.
queue.visibility #=> 30