Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Initial version of BigMessage. #1917

Merged
merged 5 commits into from
Dec 19, 2013
Merged

Initial version of BigMessage. #1917

merged 5 commits into from
Dec 19, 2013

Conversation

garnaat
Copy link
Member

@garnaat garnaat commented Dec 17, 2013

This is an initial attempt at a big message, basically an SQS message that stores it's payload in S3 and therefore allows for arbitrarily large payloads.

An example:

    import boto.sqs
    from boto.sqs.bigmessage import BigMessage

    sqs = boto.sqs.connect_to_region('us-west-2')
    queue = sqs.get_queue('myqueue')
    fp = open('/path/to/bigmessage/data')
    msg = BigMessage(queue, fp, 's3://mybucket')
    queue.write(msg)

You need to pass in a file-like object as the body of the message. You also have to pass in an s3_url to specify where the message should be stored. The s3_url should be of the form:

s3://bucket[/key]

If no key is specified, a key will be created using UUID's and the body of the message will be stored in the specified bucket using the UUID as a key. The contents of the file-like object are uploaded to that key in S3 and a reference to the new object is stored in the message body. If a bucket and key are specified, it is interpreted as specifying an existing object in S3 and no object is uploaded. The BigMessage will simply refer to the existing object in the body of the message.

When a BigMessage object is deleted, it will attempt to delete the object in S3.

Feedback on the overall operability of this implementation would be appreciated as well as feedback on the code itself.


class BigMessage(RawMessage):
"""
The BigMessage class provides arbitrarily large message payloads
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we say "up to 5Gb" (the S3 limit) here? It's unlikely someone will do it, but they should be aware & it'll give people a sense of scale.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep.

@toastdriven
Copy link
Contributor

LGTM otherwise.

@garnaat
Copy link
Member Author

garnaat commented Dec 18, 2013

Note that this would fix #1902.

cc @jamesls, @diranged

@diranged
Copy link

Excellent... I'm going to look into how to integrate this into Kombu/Celery ASAP. I'll do a more thorough review a little later today just so you have another set of eyes on this change.

@danielgtaylor
Copy link
Member

Other than the comment above this looks good 👍

@ghost ghost assigned garnaat Dec 18, 2013
return key.get_contents_as_string()

def delete(self):
RawMessage.delete(self)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you try to delete the S3 file first? If the RawMessage.delete(self) raises any exception, then the file is left over dangling in S3 land forever.

@danielgtaylor
Copy link
Member

Latest changes look good. 🚢-it

garnaat added a commit that referenced this pull request Dec 19, 2013
Initial version of BigMessage.
@garnaat garnaat merged commit e6cd665 into boto:develop Dec 19, 2013
@garnaat garnaat deleted the big-message branch December 19, 2013 21:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants