message broker sifatida redis qo'shildi

This commit is contained in:
A'zamov Samandar
2025-04-25 10:25:49 +05:00
parent 40200a4649
commit 71634fc19e
7 changed files with 163 additions and 48 deletions

View File

@@ -72,7 +72,7 @@ Notifications should be published to the RabbitMQ exchange with the following JS
}
```
Python example
Python example rabbitmq broker
```python
from kombu import Connection, Exchange, Producer
@@ -93,6 +93,28 @@ producer.publish(message)
print("Message sent to all workers!")
```
Python example redis broker
```python
import redis
import json
# Redis ulanishi
r = redis.StrictRedis(host='127.0.0.1', port=6379, db=0)
# Xabar tayyorlash
message = {
'type': 'email',
'message': "Subject: test\r\n\r\nclasscom.uz sayti va mobil ilovasiga ro'yxatdan o'tishingiz uchun tasdiqlash kodi: 1234",
'to': ["JscorpTech@gmail.com", "admin@jscorp.uz"]
}
# Xabarni JSON formatga otkazib, Redis listga push qilish
r.rpush('notification', json.dumps(message))
print("Message pushed to Redis list!")
```
Available notification types:
- `email`: For email notifications
- `sms`: For SMS notifications