How to use the aiormq.spec.Basic 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 mosquito / aio-pika / aio_pika / queue.py View on Github external
async def cancel(self, consumer_tag: ConsumerTag, timeout=None,
                     nowait: bool=False) -> aiormq.spec.Basic.CancelOk:
        """ This method cancels a consumer. This does not affect already
        delivered messages, but it does mean the server will not send any more
        messages for that consumer. The client may receive an arbitrary number
        of messages in between sending the cancel method and receiving the
        cancel-ok reply. It may also be sent from the server to the client in
        the event of the consumer being unexpectedly cancelled (i.e. cancelled
        for any reason other than the server receiving the corresponding
        basic.cancel from the client). This allows clients to be notified of
        the loss of consumers due to events such as queue deletion.

        :param consumer_tag:
            consumer tag returned by :func:`~aio_pika.Queue.consume`
        :param timeout: execution timeout
        :param bool nowait: Do not expect a Basic.CancelOk response
        :return: Basic.CancelOk when operation completed successfully
        """
github mosquito / aio-pika / aio_pika / message.py View on Github external
type=message.header.properties.message_type,
            user_id=message.header.properties.user_id,
            app_id=message.header.properties.app_id,
        )

        self.cluster_id = message.header.properties.cluster_id
        self.consumer_tag = None
        self.delivery_tag = None
        self.redelivered = None
        self.message_count = None

        if isinstance(message.delivery, aiormq.spec.Basic.GetOk):
            self.message_count = message.delivery.message_count
            self.delivery_tag = message.delivery.delivery_tag
            self.redelivered = message.delivery.redelivered
        elif isinstance(message.delivery, aiormq.spec.Basic.Deliver):
            self.consumer_tag = message.delivery.consumer_tag
            self.delivery_tag = message.delivery.delivery_tag
            self.redelivered = message.delivery.redelivered

        self.routing_key = message.delivery.routing_key
        self.exchange = message.delivery.exchange

        if no_ack or not self.delivery_tag:
            self.lock()
            self.__processed = True
github mosquito / aio-pika / aio_pika / message.py View on Github external
reply_to=message.header.properties.reply_to,
            expiration=expiration / 1000. if expiration else None,
            message_id=message.header.properties.message_id,
            timestamp=decode_timestamp(message.header.properties.timestamp),
            type=message.header.properties.message_type,
            user_id=message.header.properties.user_id,
            app_id=message.header.properties.app_id,
        )

        self.cluster_id = message.header.properties.cluster_id
        self.consumer_tag = None
        self.delivery_tag = None
        self.redelivered = None
        self.message_count = None

        if isinstance(message.delivery, aiormq.spec.Basic.GetOk):
            self.message_count = message.delivery.message_count
            self.delivery_tag = message.delivery.delivery_tag
            self.redelivered = message.delivery.redelivered
        elif isinstance(message.delivery, aiormq.spec.Basic.Deliver):
            self.consumer_tag = message.delivery.consumer_tag
            self.delivery_tag = message.delivery.delivery_tag
            self.redelivered = message.delivery.redelivered

        self.routing_key = message.delivery.routing_key
        self.exchange = message.delivery.exchange

        if no_ack or not self.delivery_tag:
            self.lock()
            self.__processed = True