Spaces:
Configuration error
Configuration error
Redis Message Queue Test Project
This project demonstrates the usage of the async-framework library with multiple queues, publishers, and consumers.
Project Structure
config.py- Configuration for Redis and broker settingsmessage_generators.py- Message generators for different queue typespublishers.py- Publishers for different queuesconsumers.py- Consumers with message handlers
Setup
Install Redis:
- Windows: Download from Redis Windows
- Linux:
sudo apt-get install redis-server - MacOS:
brew install redis
Create and activate virtual environment:
python -m venv venv
.\venv\Scripts\activate # Windows
source venv/bin/activate # Linux/MacOS
- Install dependencies:
pip install async-framework structlog
- Start Redis server:
redis-server
Running the Test
- Start the consumers:
python consumers.py
- In a new terminal, start the publishers:
python publishers.py
Message Types
Orders Queue:
- Order details with ID, customer, amount
- Simulated processing time: 0.5s
- Fails for orders > $900
Notifications Queue:
- Notification details with type and priority
- Simulated processing time: 0.3s
- High priority notifications fail twice before success
Analytics Queue:
- Event tracking data
- Simulated processing time: 0.1s
- No simulated failures
Monitoring
Access Prometheus metrics at:
http://localhost:8000
Available metrics:
- messages_published_total
- messages_processed_total
- message_processing_seconds