Get all available regions for the SQS service.
Return type: | list |
---|---|
Returns: | A list of boto.sqs.regioninfo.RegionInfo |
Represents an SQS Attribute Name/Value set
A Connection to the SQS Service.
alias of SQSError
Add a permission to a queue.
Parameters: |
|
---|---|
Return type: | bool |
Returns: | True if successful, False otherwise. |
Extends the read lock timeout for the specified message from the specified queue to the specified value.
Parameters: |
|
---|
A batch version of change_message_visibility that can act on up to 10 messages at a time.
Parameters: |
|
---|
Create an SQS Queue.
Parameters: |
|
---|---|
Return type: | |
Returns: | The newly created queue. |
Delete a message from a queue.
Parameters: |
|
---|---|
Return type: | bool |
Returns: | True if successful, False otherwise. |
Deletes a list of messages from a queue in a single request.
Parameters: |
|
---|
Delete a message from a queue, given a receipt handle.
Parameters: |
|
---|---|
Return type: | bool |
Returns: | True if successful, False otherwise. |
Delete an SQS Queue.
Parameters: |
|
---|---|
Return type: | bool |
Returns: | True if the command succeeded, False otherwise |
Retrieves all queues.
Parameters: | prefix (str) – Optionally, only return queues that start with this value. |
---|---|
Return type: | list |
Returns: | A list of boto.sqs.queue.Queue instances. |
Retrieves the dead letter source queues for a given queue.
Parameters: | queue (A boto.sqs.queue.Queue object.) – The queue for which to get DL source queues |
---|---|
Return type: | list |
Returns: | A list of boto.sqs.queue.Queue instances. |
Retrieves the queue with the given name, or None if no match was found.
Parameters: | |
---|---|
Return type: | boto.sqs.queue.Queue or None |
Returns: | The requested queue, or None if no match was found. |
Gets one or all attributes of a Queue
Parameters: | queue (A Queue object) – The SQS queue to get attributes for |
---|---|
Return type: | boto.sqs.attributes.Attributes |
Returns: | An Attributes object containing request value(s). |
Retrieves the queue with the given name, or None if no match was found.
Parameters: | |
---|---|
Return type: | boto.sqs.queue.Queue or None |
Returns: | The requested queue, or None if no match was found. |
Read messages from an SQS Queue.
Parameters: |
|
---|---|
Return type: | list |
Returns: | A list of boto.sqs.message.Message objects. |
Remove a permission from a queue.
Parameters: |
|
---|---|
Return type: | bool |
Returns: | True if successful, False otherwise. |
Send a new message to the queue.
Parameters: |
|
---|
Delivers up to 10 messages to a queue in a single request.
Parameters: |
|
---|
SQS Message
A Message represents the data stored in an SQS queue. The rules for what is allowed within an SQS Message are here:
So, at it’s simplest level a Message just needs to allow a developer to store bytes in it and get the bytes back out. However, to allow messages to have richer semantics, the Message class must support the following interfaces:
The constructor for the Message class must accept a keyword parameter “queue” which is an instance of a boto Queue object and represents the queue that the message will be stored in. The default value for this parameter is None.
The constructor for the Message class must accept a keyword parameter “body” which represents the content or body of the message. The format of this parameter will depend on the behavior of the particular Message subclass. For example, if the Message subclass provides dictionary-like behavior to the user the body passed to the constructor should be a dict-like object that can be used to populate the initial state of the message.
The Message class must provide an encode method that accepts a value of the same type as the body parameter of the constructor and returns a string of characters that are able to be stored in an SQS message body (see rules above).
The Message class must provide a decode method that accepts a string of characters that can be stored (and probably were stored!) in an SQS message and return an object of a type that is consistent with the “body” parameter accepted on the class constructor.
The Message class must provide a __len__ method that will return the size of the encoded message that would be stored in SQS based on the current state of the Message object.
The Message class must provide a get_body method that will return the body of the message in the same format accepted in the constructor of the class.
The Message class must provide a set_body method that accepts a message body in the same format accepted by the constructor of the class. This method should alter to the internal state of the Message object to reflect the state represented in the message body parameter.
The Message class must provide a get_body_encoded method that returns the current body of the message in the format in which it would be stored in SQS.
The EncodedMHMessage class provides a message that provides RFC821-like headers like this:
HeaderName: HeaderValue
This variation encodes/decodes the body of the message in base64 automatically. The message instance can be treated like a mapping object, i.e. m[‘HeaderName’] would return ‘HeaderValue’.
The MHMessage class provides a message that provides RFC821-like headers like this:
HeaderName: HeaderValue
The encoding/decoding of this is handled automatically and after the message body has been read, the message instance can be treated like a mapping object, i.e. m[‘HeaderName’] would return ‘HeaderValue’.
The default Message class used for SQS queues. This class automatically encodes/decodes the message body using Base64 encoding to avoid any illegal characters in the message body. See:
https://forums.aws.amazon.com/thread.jspa?threadID=13067
for details on why this is a good idea. The encode/decode is meant to be transparent to the end-user.
Base class for SQS messages. RawMessage does not encode the message in any way. Whatever you store in the body of the message is what will be written to SQS and whatever is returned from SQS is stored directly into the body of the message.
Transform seralized byte array into any object.
Transform body object into serialized byte array format.
This method is really a semi-private method used by the Queue.write method when writing the contents of the message to SQS. You probably shouldn’t need to call this method in the normal course of events.
Override the current body for this object, using decoded format.
Represents an SQS Queue
Add a permission to a queue.
Parameters: |
|
---|---|
Return type: | bool |
Returns: | True if successful, False otherwise. |
A batch version of change_message_visibility that can act on up to 10 messages at a time.
Parameters: | messages (List of tuples.) – A list of tuples where each tuple consists of a boto.sqs.message.Message object and an integer that represents the new visibility timeout for that message. |
---|
Utility function to remove all messages from a queue
Utility function to count the number of messages in a queue. Note: This function now calls GetQueueAttributes to obtain an ‘approximate’ count of the number of messages in a queue.
Deprecated. This is the old ‘count’ method that actually counts the messages by reading them all. This gives an accurate count but is very slow for queues with non-trivial number of messasges. Instead, use get_attributes(‘ApproximateNumberOfMessages’) to take advantage of the new SQS capability. This is retained only for the unit tests.
Delete the queue.
Delete a message from the queue.
Parameters: | message (boto.sqs.message.Message) – The boto.sqs.message.Message object to delete. |
---|---|
Return type: | bool |
Returns: | True if successful, False otherwise |
Deletes a list of messages in a single request.
Parameters: | messages (List of boto.sqs.message.Message objects.) – A list of message objects. |
---|
Utility function to dump the messages in a queue to a file NOTE: Page size must be < 10 else SQS errors
Retrieves attributes about this queue object and returns them in an Attribute instance (subclass of a Dictionary).
Parameters: | attributes (string) – String containing one of: ApproximateNumberOfMessages, ApproximateNumberOfMessagesNotVisible, VisibilityTimeout, CreatedTimestamp, LastModifiedTimestamp, Policy ReceiveMessageWaitTimeSeconds |
---|---|
Return type: | Attribute object |
Returns: | An Attribute object which is a mapping type holding the requested name/value pairs |
Get a variable number of messages.
Parameters: |
|
---|---|
Return type: | list |
Returns: | A list of boto.sqs.message.Message objects. |
Get the visibility timeout for the queue.
Return type: | int |
---|---|
Returns: | The number of seconds as an integer. |
Utility function to load messages from a local filename to a queue
Utility function to load messages from a file-like object to a queue
Utility function to load messages from a local filename to a queue
Load messages previously saved to S3.
Create new message of appropriate class.
Parameters: | body (message body) – The body of the newly created message (optional). |
---|---|
Return type: | boto.sqs.message.Message |
Returns: | A new Message object |
Read a single message from the queue.
Parameters: |
|
---|---|
Return type: | |
Returns: | A single message or None if queue is empty |
Remove a permission from a queue.
Parameters: | label (str or unicode) – The unique label associated with the permission being removed. |
---|---|
Return type: | bool |
Returns: | True if successful, False otherwise. |
Read all messages from the queue and persist them to local file. Messages are written to the file and the ‘sep’ string is written in between messages. Messages are deleted from the queue after being written to the file. Returns the number of messages saved.
Read all messages from the queue and persist them to file-like object. Messages are written to the file and the ‘sep’ string is written in between messages. Messages are deleted from the queue after being written to the file. Returns the number of messages saved.
Read all messages from the queue and persist them to local file. Messages are written to the file and the ‘sep’ string is written in between messages. Messages are deleted from the queue after being written to the file. Returns the number of messages saved.
Read all messages from the queue and persist them to S3. Messages are stored in the S3 bucket using a naming scheme of:
<queue_id>/<message_id>
Messages are deleted from the queue after being saved to S3. Returns the number of messages saved.
Set a new value for an attribute of the Queue.
Parameters: |
|
---|---|
Return type: | bool |
Returns: | True if successful, otherwise False. |
Set the message class that should be used when instantiating messages read from the queue. By default, the class boto.sqs.message.Message is used but this can be overriden with any class that behaves like a message.
Parameters: | message_class (Message-like class) – The new Message class |
---|
Set the visibility timeout for the queue.
Parameters: | visibility_timeout (int) – The desired timeout in seconds |
---|
Add a single message to the queue.
Parameters: | message (Message) – The message to be written to the queue |
---|---|
Return type: | boto.sqs.message.Message |
Returns: | The boto.sqs.message.Message object that was written. |
Delivers up to 10 messages in a single request.
Parameters: | messages (List of lists.) – A list of lists or tuples. Each inner tuple represents a single message to be written and consists of and ID (string) that must be unique within the list of messages, the message body itself which can be a maximum of 64K in length, an integer which represents the delay time (in seconds) for the message (0-900) before the message will be delivered to the queue, and an optional dict of message attributes like those passed to send_message in the connection class. |
---|
A set of results returned by SendMessageBatch.
A container for the results of a send_message_batch request.
Variables: |
|
---|
The result (successful or unsuccessful) of a single message within a send_message_batch request.
In the case of a successful result, this dict-like object will contain the following items:
Variables: |
|
---|
In the case of an error, this object will contain the following items:
Variables: |
|
---|