gundi-dlq-processor
A Python tool for processing messages from Google Cloud Pub/Sub dead letter queues (DLQs) in the Gundi system. This tool allows you to reprocess failed messages or purge them from the queue.
What it does
The gundi-dlq-processor is designed to handle messages that have failed processing and ended up in dead letter queues. It provides two main operations:
- Reprocess: Pull messages from a DLQ subscription and republish them to a target topic for reprocessing
- Purge: Remove messages from a DLQ subscription without reprocessing them
The tool includes filtering capabilities to selectively process messages based on various criteria like message type, connection ID, system ID, gundi ID, and source ID.
Features
- Batch Processing: Process messages in configurable batch sizes
- Message Filtering: Filter messages by multiple criteria
- Safe Operations: Confirmation prompts for destructive operations
- Continuous Processing: Option to continuously process messages until interrupted
- Error Handling: Automatic retry on errors
- Detailed Logging: Clear output showing which messages are processed or excluded
Installation
# Install from PyPI
pip install gundi-dlq
# Or install from source
git clone <repository-url>
cd gundi-dlq-processor
pip install -e .
Usage
Basic Commands
# Reprocess messages from DLQ to a target topic
gundi-dlq --from-sub <subscription-id> --reprocess --to-topic <topic-id>
# Purge messages from DLQ (with confirmation)
gundi-dlq --from-sub <subscription-id> --purge
# Process with custom batch size
gundi-dlq --from-sub <subscription-id> --reprocess --to-topic <topic-id> --batch-size 50
Command Line Options
| Option | Required | Default | Description |
|---|---|---|---|
--from-sub |
Yes | - | Subscription ID to pull messages from |
--to-topic |
No* | - | Topic ID to publish messages to (required with --reprocess) |
--project |
No | cdip-prod1-78ca |
GCP Project ID |
--reprocess |
No* | False | Reprocess messages from the source subscription |
--purge |
No* | False | Purge messages from the source subscription |
--batch-size |
No | 100 | Number of messages to pull per batch iteration |
--continue |
No | False | Continue processing messages until interrupted |
--msg-type |
No | - | Message types to include in reprocessing (can specify multiple) |
--msg-type-exclude |
No | - | Message types to exclude from reprocessing (can specify multiple) |
--connection |
No | - | Connection ID to filter messages by |
--system-id |
No | - | System Event ID to filter messages by |
--gundi-id |
No | - | Gundi ID to filter messages by |
--source-id |
No | - | Source ID to filter messages by |
*Either --reprocess or --purge must be specified, but not both.
Examples
Reprocess all messages from a DLQ
gundi-dlq --from-sub my-dlq-subscription --reprocess --to-topic my-target-topic
Purge all messages from a DLQ
gundi-dlq --from-sub my-dlq-subscription --purge
Reprocess only specific message types
gundi-dlq --from-sub my-dlq-subscription --reprocess --to-topic my-target-topic --msg-type observation --msg-type alert
Exclude specific message types
gundi-dlq --from-sub my-dlq-subscription --reprocess --to-topic my-target-topic --msg-type-exclude error --msg-type-exclude debug
Filter by connection ID
gundi-dlq --from-sub my-dlq-subscription --reprocess --to-topic my-target-topic --connection connection-123
Filter by multiple criteria
gundi-dlq --from-sub my-dlq-subscription --reprocess --to-topic my-target-topic --gundi-id gundi-456 --source-id source-789 --batch-size 50
Continuous processing
gundi-dlq --from-sub my-dlq-subscription --reprocess --to-topic my-target-topic --continue
Message Filtering
The tool supports filtering messages based on several criteria:
- Message Type: Include or exclude specific event types
- Connection ID: Filter by data provider connection
- System ID: Filter by system event ID
- Gundi ID: Filter by gundi identifier
- Source ID: Filter by external source ID
When filters are applied, messages that don't match the criteria are left in the queue and not processed.
Safety Features
- Purge Confirmation: When using
--purge, the tool prompts for confirmation before deleting messages - Batch Processing: Messages are processed in configurable batches to avoid overwhelming the system
- Error Recovery: The tool automatically retries on errors and continues processing
- Detailed Output: Clear logging shows which messages are processed, excluded, or discarded
Output Format
The tool provides detailed output showing:
- Number of messages pulled from the subscription
- Which messages are being processed or excluded
- Filtering criteria applied
- Final count of processed messages (e.g., "5/10 messages reprocessed")
Dependencies
click: Command line interfacegcloud.aio.pubsub: Google Cloud Pub/Sub async clientasyncio: Asynchronous programming support
Authentication
The tool uses Google Cloud authentication. Ensure you have:
- Google Cloud SDK installed and configured
- Appropriate permissions to access the Pub/Sub resources
- Application Default Credentials set up
# Set up authentication
gcloud auth application-default login
Error Handling
The tool includes robust error handling:
- Automatic retry on connection errors
- Graceful handling of malformed messages
- Clear error messages for configuration issues
- Safe exit on user interruption
Contributing
When contributing to this project:
- Follow the existing code style
- Add tests for new features
- Update documentation for any new options
- Ensure error handling is comprehensive
Release files for gundi-dlq 0.3.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 | |
|---|---|---|---|
| gundi_dlq-0.3.0.tar.gz | 24.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gundi_dlq-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.1 kB
Release files / gundi_dlq-0.3.0.tar.gz
| Download URL | gundi_dlq-0.3.0.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
862ff7c80356d3d33b616c7a2bfce6034b685a191452a99948f23967b137a683
|
|
BLAKE2b-256 checksum How to use checksums |
aacfd1ede2ae9320d8abfc8ac8f4d978ca63d208d95163fafa99c4b8f189b4a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency logRelease files / gundi_dlq-0.3.0-py3-none-any.whl
| Download URL | gundi_dlq-0.3.0-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
92706d4d38b9816113152a174806eb8b06d6e2438fb780c3808da24793c906d9
|
|
BLAKE2b-256 checksum How to use checksums |
15e5aa9270db74f05337aeca8fa88d18065e47595672f98604b90584703b4da8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 29, 2026.
Transparency log