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.3.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.3-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: boto3_large_message_utils-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 4f5a4c96e6e48167f08841f661308934627cb0f18966b419fa3a191e893b842a
MD5 f7b206beca9c00e0c530c0dc719b44ed
BLAKE2b-256 4ef8e6ec2418a6425c95488977c7d71014d79058207374e6674a9dc57453efae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: boto3_large_message_utils-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a3dd30ed0a011a341f4497e2c746aeb006de3f84b342a48a81c06c0299a1052e
MD5 b4ecc9382895b6692e7e0667e00b310f
BLAKE2b-256 c62f752ec4b14b9b727c79e48eae1ea9894e201b926b2a24813ee20ee5ba8d23

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