AWS SQS extended client functionality from amazon-sqs-java-extended-client-lib
Project description
sqs-extended-client
Implements the functionality of amazon-sqs-java-extended-client-lib in Python
Installation
pip install sqs-extended-client
Overview
sqs-extended-client allows for sending large messages through SQS via S3. This is the same mechanism that the Amazon library amazon-sqs-java-extended-client-lib provides. This library is interoperable with that library.
To do this, this library automatically extends the normal boto3 SQS client and Queue resource classes upon import using the botoinator library. This allows for further extension or decoration if desired.
Additional attributes available on boto3
SQS client
and Queue
objects
- large_payload_support -- the S3 bucket name that will store large messages.
- message_size_threshold -- the threshold for storing the message in the large messages bucket. Cannot be less than
0
or greater than262144
. Defaults to262144
. - always_through_s3 -- if
True
, then all messages will be serialized to S3. Defaults toFalse
- s3 -- the boto3 S3
resource
object to use to store objects to S3. Use this if you want to control the S3 resource (for example, custom S3 config or credentials). Defaults toboto3.resource("s3")
on first use if not previously set.
Usage
Note:
The s3 bucket must already exist prior to usage, and be accessible by whatever credentials you have available
Enabling support for large payloads (>256Kb)
import boto3
import sqs_extended_client
# Low level client
sqs = boto3.client('sqs')
sqs.large_payload_support = 'my-bucket-name'
# boto resource
resource = boto3.resource('sqs')
queue = resource.Queue('queue-url')
# Or
queue = resource.create_queue(QueueName='queue-name')
queue.large_payload_support = 'my-bucket-name'
Enabling support for large payloads (>64K)
import boto3
import sqs_extended_client
# Low level client
sqs = boto3.client('sqs')
sqs.large_payload_support = 'my-bucket-name'
sqs.message_size_threshold = 65536
# boto resource
resource = boto3.resource('sqs')
queue = resource.Queue('queue-url')
# Or
queue = resource.create_queue(QueueName='queue-name')
queue.large_payload_support = 'my-bucket-name'
queue.message_size_threshold = 65536
Enabling support for large payloads for all messages
import boto3
import sqs_extended_client
# Low level client
sqs = boto3.client('sqs')
sqs.large_payload_support = 'my-bucket-name'
sqs.always_through_s3 = True
# boto resource
resource = boto3.resource('sqs')
queue = resource.Queue('queue-url')
# Or
queue = resource.create_queue(QueueName='queue-name')
queue.large_payload_support = 'my-bucket-name'
queue.always_through_s3 = True
Setting a custom S3 resource
import boto3
from botocore.config import Config
import sqs_extended_client
# Low level client
sqs = boto3.client('sqs')
sqs.large_payload_support = 'my-bucket-name'
sqs.s3 = boto3.resource(
's3',
config=Config(
signature_version='s3v4',
s3={
"use_accelerate_endpoint": True
}
)
)
# boto resource
resource = boto3.resource('sqs')
queue = resource.Queue('queue-url')
# Or
queue = resource.create_queue(QueueName='queue-name')
queue.large_payload_support = 'my-bucket-name'
queue.s3 = boto3.resource(
's3',
config=Config(
signature_version='s3v4',
s3={
"use_accelerate_endpoint": True
}
)
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for sqs-extended-client-0.0.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c69b6fc45ea3d49ad16572fc1f4289faf2c76fa6fe879578f6cb3c8f766e31c |
|
MD5 | 088cb1ab791e3bc12339ade7325b66a5 |
|
BLAKE2b-256 | 28c060f0ccd54db82edfee28077dd1439d1438cd8b1a139b2b87fb862b8a8869 |
Close
Hashes for sqs_extended_client-0.0.10-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05357f8ff7fd0776bd8ed3f74d5091f0168a254bfec8f726543a74684b55ce2a |
|
MD5 | 7fd46e6cde2c17fc040cb9c67d290c38 |
|
BLAKE2b-256 | c682621b3aa668cb6b3e25fbf074c069720a657ab8f1c0037d48e6901a301cd8 |