Commit
·
05be9a1
1
Parent(s):
d0eeff5
- rabbit_base.py +9 -1
rabbit_base.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
-
# rabbit_base.py
|
| 2 |
from typing import Callable, Dict, List, Optional
|
| 3 |
import aio_pika
|
| 4 |
from urllib.parse import urlsplit, unquote
|
| 5 |
from config import settings
|
|
|
|
| 6 |
|
| 7 |
ExchangeResolver = Callable[[str], str] # exchangeName -> exchangeType
|
| 8 |
|
|
@@ -35,7 +35,15 @@ class RabbitBase:
|
|
| 35 |
async def connect(self) -> None:
|
| 36 |
if self._conn and not self._conn.is_closed:
|
| 37 |
return
|
|
|
|
| 38 |
conn_kwargs = _parse_amqp_url(str(settings.AMQP_URL))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
self._conn = await aio_pika.connect_robust(**conn_kwargs)
|
| 40 |
self._chan = await self._conn.channel()
|
| 41 |
await self._chan.set_qos(prefetch_count=settings.RABBIT_PREFETCH)
|
|
|
|
|
|
|
| 1 |
from typing import Callable, Dict, List, Optional
|
| 2 |
import aio_pika
|
| 3 |
from urllib.parse import urlsplit, unquote
|
| 4 |
from config import settings
|
| 5 |
+
import ssl # ✅ correct import
|
| 6 |
|
| 7 |
ExchangeResolver = Callable[[str], str] # exchangeName -> exchangeType
|
| 8 |
|
|
|
|
| 35 |
async def connect(self) -> None:
|
| 36 |
if self._conn and not self._conn.is_closed:
|
| 37 |
return
|
| 38 |
+
|
| 39 |
conn_kwargs = _parse_amqp_url(str(settings.AMQP_URL))
|
| 40 |
+
|
| 41 |
+
# Disable SSL verification if using TLS
|
| 42 |
+
if conn_kwargs.get("ssl"):
|
| 43 |
+
conn_kwargs["ssl_options"] = {
|
| 44 |
+
"cert_reqs": ssl.CERT_NONE
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
self._conn = await aio_pika.connect_robust(**conn_kwargs)
|
| 48 |
self._chan = await self._conn.channel()
|
| 49 |
await self._chan.set_qos(prefetch_count=settings.RABBIT_PREFETCH)
|