#!/usr/bin/env python
# -*- coding=utf8 -*-
import asyncio
from typing import Union
from yarl import URL
from pamqp import specification as spec
from aio_pika.exceptions import ChannelClosed
from aio_pika import RobustConnection, RobustChannel, Message
from aiormq.types import ConsumerCallback, ArgumentsType, TimeoutType
from common import config, logger
class AChannel(RobustChannel):
async def publish(
self,
message: Message,
routing_key: str,
*,
mandatory: bool = True,
immediate: bool = False,
timeout: Union[int, float] = None
):
if self.default_exchange is None:
logger.error("PublishMessageFailed: channel not connected")
return None
return await self.default_exchange.channel.publish(
message,
routing_key,
mandatory=mandatory,
immediate=immediate,
tim
python rabbitmq demo
于 2021-10-15 17:38:07 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)