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 LargeMessageBuilder

from boto3_large_message_utils import LargeMessageBuilder

builder = LargeMessageBuilder(
    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, build expects a string
msg = json.dumps({ 'content': 'this is my message' })

# submit your message to the handler
new_msg = builder.build(msg)
# send message to SQS, SNS or another AWS service

Message with Message Attributes

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

# submit your message to the handler
msg = builder.build(msg, msg_attr)
# send message to SQS, SNS or another AWS service

Parse a message

Handle a message that has been optimised by the Base.

# received message from SQS or another AWS service.
parser = LargeMessageParser(
    #session=session, # Pass an optional boto3 session to initialise the client from the session
)
msg = parser.parse(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.1.2.tar.gz (5.5 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.1.2-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: boto3_large_message_utils-0.1.2.tar.gz
  • Upload date:
  • Size: 5.5 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.1.2.tar.gz
Algorithm Hash digest
SHA256 3aec8f1121e7cda6b2bd300da851e21d6473efc3bffccafb835130ed666aa028
MD5 07a9b50f21577f09ed8c3922df96b81d
BLAKE2b-256 a0ad2a20f108efebda1a7c49bf0f878fe78edb089eb545c34a8365975ba69b90

See more details on using hashes here.

File details

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

File metadata

  • Download URL: boto3_large_message_utils-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.3 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.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f222a209cd412d365d49a43200d34573f9ce2a98943b12d65e501eef832ce2b
MD5 de35d0723348aed8a5c98663cf78b94b
BLAKE2b-256 176f99a3cf74caf5295c50abd9d4740567666defead23808215c0956348f61be

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