RabbitMQ uchun Python misoli qo'shildi

This commit is contained in:
A'zamov Samandar
2025-04-21 13:08:16 +05:00
parent 86353820da
commit 79ac9e16d0

View File

@@ -72,6 +72,27 @@ Notifications should be published to the RabbitMQ exchange with the following JS
} }
``` ```
Python example
```python
from kombu import Connection, Exchange, Producer
# RabbitMQ ulanishi
rabbit_url = 'amqp://guest:guest@127.0.0.1:5672/'
connection = Connection(rabbit_url)
channel = connection.channel()
exchange = Exchange('notification', type='direct')
# Producer yaratish
producer = Producer(channel, exchange=exchange, routing_key="notification")
# Xabar yuborish
message = {'type': 'sms', 'message': "classcom.uz sayti va mobil ilovasiga ro'yxatdan o'tishingingiz uchun tasdiqlash kodi: 1234", "to": ["+998888112309", "+998943990509"]}
producer.publish(message)
print("Message sent to all workers!")
```
Available notification types: Available notification types:
- `email`: For email notifications - `email`: For email notifications
- `sms`: For SMS notifications - `sms`: For SMS notifications