Leanmq

Latest version: v0.2.0

Safety actively analyzes 723217 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.2.0

LeanMQ now supports Webhooks natively and includes a bundled webhook service to make it easier to get started.

Updates

- Add `LeanMQWebhook` to make it easier to replace webhooks with a few lines of code
- Bundle `WebhookService` for processing webhook messages in dedicated worker threads
- Use it with `webhook.run_service()`
- Massively improve docs with guides, a reference, and examples.

0.1.0

Initial public release of LeanMQ, a simple and efficient message queue system built on Redis Streams.

Features

- **Simple yet powerful API**: Easy to integrate into any Python application
- **Redis Streams foundation**: Leverages Redis's robust and efficient stream implementation
- **Queue management**:
- Create and manage queue pairs (main queue + dead letter queue)
- List, modify, and delete queues
- Track queue information (message counts, pending messages)
- **Message operations**:
- Send messages with optional custom IDs and TTL (time-to-live)
- Retrieve messages with blocking or non-blocking operations
- Acknowledge processed messages
- Delete messages from queues
- Move failed messages to dead letter queues
- Requeue messages from DLQ back to main queue
- **Consumer groups**: Support for multiple consumers processing messages from the same queue
- **Atomic transactions**: Send multiple messages across different queues in a single atomic operation
- **Message tracking**: Track delivery attempts, failures, and processing history
- **Error handling**: Robust handling of connection issues and Redis failures

Installation


pip install leanmq


Quick Start

python
from leanmq import LeanMQ

Initialize with Redis connection details
mq = LeanMQ(redis_host="localhost", redis_port=6379)

Create a queue pair (main queue and dead letter queue)
main_queue, dlq = mq.create_queue_pair("notifications")

Send a message
msg_id = main_queue.send_message({"type": "email", "recipient": "userexample.com"})

Get messages
messages = main_queue.get_messages(count=5)

Process messages
for msg in messages:
try:
Process message...
main_queue.acknowledge_messages([msg.id])
except Exception as e:
main_queue.move_to_dlq([msg.id], f"Error: {e}", dlq)


Requirements

- Python 3.11+
- Redis 5.0+ (for Streams support)

License

Apache-2.0

Links

Releases

Has known vulnerabilities

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.