File size: 1,729 Bytes
2452e46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# 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