Class | RightAws::SqsGen2::Queue |
In: |
lib/sqs/right_sqs_gen2.rb
|
Parent: | Object |
name | [R] | |
sqs | [R] | |
url | [R] |
Add permission to the queue.
queue.add_permissions('testLabel',['125074342641', '125074342642'], ['SendMessage','SendMessage','ReceiveMessage']) #=> true
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. If the name of attribute is set, returns its value. Otherwise, returns a hash of attributes.
queue.get_attribute(‘VisibilityTimeout’) #=> {"VisibilityTimeout"=>"45"}
P.S. This guy is deprecated. Use get_attributes instead.
Retrieves queue attributes.
queue.get_attributes #=> {"ApproximateNumberOfMessages" => "0", "LastModifiedTimestamp" => "1240946032", "CreatedTimestamp" => "1240816887", "VisibilityTimeout" => "30", "Policy" => "{"Version":"2008-10-17","Id":...}"} queue.get_attributes("LastModifiedTimestamp", "VisibilityTimeout") #=> {"LastModifiedTimestamp" => "1240946032", "VisibilityTimeout" => "30"}
Get current permissions set. The set is JSON packed.
sqs.get_permissions #=> '{"Version":"2008-10-17","Id":"/826693181925/kd-test-gen-2_5/SQSDefaultPolicy", "Statement":[{"Sid":"kd-perm-04","Effect":"Allow","Principal":{"AWS":"100000000001", "AWS":"100000000001","AWS":"100000000002"},"Action":["SQS:SendMessage","SQS:DeleteMessage", "SQS:ReceiveMessage"],"Resource":"/826693181925/kd-test-gen-2_5"},{"Sid":"kd-perm-03", "Effect":"Allow","Principal":{"AWS":"648772224137"},"Action":"SQS:SendMessage", "Resource":"/826693181925/kd-test-gen-2_5"}]}'
Pops (and deletes) first accessible message from queue. Returns Message instance or nil if the queue is empty.
queue.pop #=> #<RightAws::SqsGen2::Message:0xb7bf0884 ... > # pop a message with custom attributes m = queue.pop(['SenderId', 'SentTimestamp']) #=> #<RightAws::SqsGen2::Message:0xb7bf1884 ... > m.attributes #=> {"SentTimestamp"=>"1240991906937", "SenderId"=>"800000000005"}
Retrieves first accessible message from queue. Returns Message instance or nil it the queue is empty.
queue.receive #=> #<RightAws::SqsGen2::Message:0xb7bf0884 ... >
Retrieves several messages from queue. Returns an array of Message instances.
queue.receive_messages(2,10) #=> array of messages
Revoke any permissions in the queue policy that matches the label parameter.
sqs.remove_permissions('testLabel') # => true
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 VisibilityTimeout value for the queue. Returns new timeout value.
queue.visibility #=> 30