Skip to main content

This library provides a way of bypassing AWS size restrictions when using services such as SQS and SNS.

Project description

boto3_large_message_utils

This library provides a way of bypassing AWS size restrictions when using services such as SQS and SNS, by providing methods to cache message bodies in S3 and parse them again at the other end.

Usage

Install

Install the package using pip

pip install boto3_large_message_utils

Initialise Handler

Import and set up the LargeMessageHandler

from boto3_large_message_utils import LargeMessageHandler

msg_handler = LargeMessageHandler(
    s3_bucket_for_cache='my-bucket', #REQUIRED
    s3_object_prefix='my-prefix',
    compress=True,
    #message_size_threshold=100000, # Pass an optional message size threshold
    #session=session, # Pass an optional boto3 session to initialise the client from the session
)

Handle a message

# create your message in the normal way, submit_message expects a string
my_message = json.dumps({ 'content': 'this is my message' })

# submit your message to the handler
message = msg_handler.submit_message(my_message)
# send message to SQS, SNS or another AWS service

Message with Message Attributes

# create your message in the normal way, submit_message expects a string
my_message = json.dumps({ 'content': 'this is my message' })
message_attributes = {
    "MSG_ATTR": {
        "StringValue": "my-value"
    }
}

# submit your message to the handler
message = msg_handler.submit_message(my_message, message_attributes)
# send message to SQS, SNS or another AWS service

Parse a message

Handle a message that has been optimised by the LargeMessageHandler.

# received message from SQS or another AWS service.
my_message = msg_handler.parse_message(received_message)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

boto3_large_message_utils-0.0.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

boto3_large_message_utils-0.0.3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file boto3_large_message_utils-0.0.3.tar.gz.

File metadata

  • Download URL: boto3_large_message_utils-0.0.3.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for boto3_large_message_utils-0.0.3.tar.gz
Algorithm Hash digest
SHA256 7af1712a64f2a98ccbed095674e43e0526b262816cab02de9d13b8e23fd2836b
MD5 20f847f68b4f2b9e37e85c32c721f343
BLAKE2b-256 c31151ebc7c73a27d6ce8378a16d4d4dff1a4b0e0b83756668a92bbcecbf7fa4

See more details on using hashes here.

File details

Details for the file boto3_large_message_utils-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: boto3_large_message_utils-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for boto3_large_message_utils-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d46168844c133396237ea7a584f2a2673ce62c667ee9d9b9d9bdf45173ba6f33
MD5 df0541cac207451d85364bc33d8b63e2
BLAKE2b-256 dadac2a6157fb5383aa5b45ee0d4bfe2a6dacabd5fe6edcdf87f92d9cdf6c231

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page