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 settings | |
| - `message_generators.py` - Message generators for different queue types | |
| - `publishers.py` - Publishers for different queues | |
| - `consumers.py` - Consumers with message handlers | |
| ## Setup | |
| 1. Install Redis: | |
| - Windows: Download from [Redis Windows](https://github.com/microsoftarchive/redis/releases) | |
| - Linux: `sudo apt-get install redis-server` | |
| - MacOS: `brew install redis` | |
| 2. Create and activate virtual environment: | |
| ```bash | |
| python -m venv venv | |
| .\venv\Scripts\activate # Windows | |
| source venv/bin/activate # Linux/MacOS | |
| ``` | |
| 3. Install dependencies: | |
| ```bash | |
| pip install async-framework structlog | |
| ``` | |
| 4. Start Redis server: | |
| ```bash | |
| redis-server | |
| ``` | |
| ## Running the Test | |
| 1. Start the consumers: | |
| ```bash | |
| python consumers.py | |
| ``` | |
| 2. In a new terminal, start the publishers: | |
| ```bash | |
| python publishers.py | |
| ``` | |
| ## Message Types | |
| 1. Orders Queue: | |
| - Order details with ID, customer, amount | |
| - Simulated processing time: 0.5s | |
| - Fails for orders > $900 | |
| 2. Notifications Queue: | |
| - Notification details with type and priority | |
| - Simulated processing time: 0.3s | |
| - High priority notifications fail twice before success | |
| 3. 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 | |