How to use the aiormq.types.DeliveredMessage function in aiormq

To help you get started, we’ve selected a few aiormq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seatgeek / amqp-dispatcher / tests / unit / test_message.py View on Github external
def test_incoming_message_to_message():
    raw_message = IncomingMessage(
        message=DeliveredMessage(
            delivery=Basic.Deliver(
                consumer_tag="ctag",
                delivery_tag="dtag",
                redelivered=True,
                exchange="exc",
                routing_key="rkey",
            ),
            header=ContentHeader(),
            body=b"",
            channel=None,
        )
    )

    message = Message(raw_message=raw_message)

    assert message.delivery_info["consumer_tag"], "ctag"
github mosquito / aio-pika / aio_pika / types.py View on Github external
from typing import Union, Callable, Any
import aiormq.types


ReturnCallbackType = Callable[[aiormq.types.DeliveredMessage], Any]
CloseCallbackType = Callable[[Exception], Any]
TimeoutType = Union[int, float]
ExchangeType = Union['Exchange', str]
github mosquito / aiormq / aiormq / channel.py View on Github external
async def _read_content(self, frame, header: ContentHeader):
        body = BytesIO()

        content = None
        if header.body_size:
            content = await self._get_frame()  # type: ContentBody

        while content and body.tell() < header.body_size:
            body.write(content.value)

            if body.tell() < header.body_size:
                content = await self._get_frame()

        # noinspection PyTypeChecker
        return DeliveredMessage(
            delivery=frame, header=header, body=body.getvalue(), channel=self
        )
github mosquito / aiormq / aiormq / channel.py View on Github external
async def basic_get(
        self, queue: str = "", no_ack: bool = False
    ) -> typing.Optional[DeliveredMessage]:

        async with self.getter_lock:
            self.getter = self.create_future()
            await self.rpc(spec.Basic.Get(queue=queue, no_ack=no_ack))
            frame, message = await self.getter
            self.getter = None

        return message