dramatiq_sqs
A Dramatiq broker that can be used with Amazon SQS.
The backend uses boto3 under the hood. For details on how authorization works, check out its docs.
Installation
pip install dramatiq_sqs
Usage
import dramatiq
from dramatiq.middleware import (
AgeLimit,
TimeLimit,
Callbacks,
Pipelines,
Prometheus,
Retries,
)
from dramatiq_sqs import SQSBroker
broker = SQSBroker(
namespace="dramatiq_sqs_tests",
middleware=[
Prometheus(),
AgeLimit(),
TimeLimit(),
Callbacks(),
Pipelines(),
Retries(min_backoff=1000, max_backoff=900000, max_retries=96),
],
)
dramatiq.set_broker(broker)
Dead-letter queues
DLQs are enabled and used by default. Note that SQS-native "dead-letter queues" aka redrive policies are not used. These are normal queues and the nacks are handled client-side by Dramatiq.
DLQs may be disabled globally, in this case failed messages will simply get deleted:
broker = SQSBroker(dl_queues_enabled=False)
Keep in mind that while you may still set up redrive policies externally, some
mechanisms like Retries and graceful shutdowns will not work as advertised
anymore, as Dramatiq can't have any control over SQS ReceiveCounts.
Automatic queue provisioning
By default, in line with the behaviour of the built-in brokers, dramatiq-sqs
will attempt to create all declared queues in SQS if they don't exist and set the
queue attributes and tags. This includes DLQs, if enabled. None of the attribute
defaults are decided by dramatiq-sqs, nor is setting them required for normal
operation, so this is a purely optional customization mechanism.
broker = SQSBroker(
queue_attributes={"MaximumMessageSize": str(1024 * 1024)},
dl_queue_attributes={
"MaximumMessageSize": str(1024 * 1024),
"MessageRetentionPeriod": str(24 * 3600),
},
tags={"managed-by": "dramatiq"},
)
Supported Amazon SQS attributes
If all this is undesired (e.g. if the queues are defined statically via IaC), queue management may be disabled completely:
broker = SQSBroker(manage_queues=False)
SQS IAM permissions required
Below is an example of an identity-based IAM policy that allows queue usage as well as auto-provisioning.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "UseSQSQueues",
"Effect": "Allow",
"Action": [
"sqs:ChangeMessageVisibility",
"sqs:ChangeMessageVisibilityBatch",
"sqs:DeleteMessage",
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl",
"sqs:PurgeQueue",
"sqs:ReceiveMessage",
"sqs:SendMessage",
"sqs:SendMessageBatch",
],
"Resource": ["*"]
},
{
"Sid": "ManageSQSQueues",
"Effect": "Allow",
"Action": [
"sqs:CreateQueue",
"sqs:SetQueueAttributes",
"sqs:TagQueue",
],
"Resource": ["*"]
}
]
}
License
dramatiq_sqs is licensed under Apache 2.0.
Metadata
Release files for dramatiq-sqs 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dramatiq_sqs-0.6.0.tar.gz | 9.1 kB | Without provenance | Details for dramatiq_sqs-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dramatiq_sqs-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for dramatiq_sqs-0.6.0-py3-none-any.whl |
Total release size: 19.6 kB
Release files / dramatiq_sqs-0.6.0.tar.gz
| Download URL | dramatiq_sqs-0.6.0.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
752ea99e437a779c3aadef9bf47314188d955f88358e19b1158c7dc79643c681
|
|
BLAKE2b-256 checksum How to use checksums |
7beb88ad091c0a04b5f0a75c95180487768813a382e520bd4aa3e783285a981e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / dramatiq_sqs-0.6.0-py3-none-any.whl
| Download URL | dramatiq_sqs-0.6.0-py3-none-any.whl |
|---|---|
| Size | 10.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
15decace6245427eb34ca28c5b59d28906305c83b0f59018bf976394f33157c9
|
|
BLAKE2b-256 checksum How to use checksums |
cdf76fac05eef967c15c574dc89f8a8e96305f452115e85c56be5a3323cff195
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for dramatiq-sqs 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.