예제 #1
0
    def confirm_delivery(self, callback=None, nowait=False):
        """
        Turn on Confirm mode in the channel. Pass in a callback to be notified
        by the Broker when a message has been confirmed as received (Basic.Ack
        from the broker to the publisher).

        For more information see:
            http://www.rabbitmq.com/extensions.html#confirms
        """
        # Validate we can do this (that the server supports it)
        if not self.transport.connection.publisher_confirms or \
           not self.transport.connection.basic_nack:
            raise exceptions.MethodNotImplemented("Not Supported on Server")

        # Add the delivery confirmation callbacks
        if callback:
            # Register the SelectOk
            self.callbacks.add(self.channel_number, spec.Confirm.SelectOk,
                               callback, False)

            # Register the ack
            self.callbacks.add(self.channel_number, spec.Basic.Ack, callback,
                               False)

            # Register the nack too
            self.callbacks.add(self.channel_number, spec.Basic.Nack, callback,
                               False)

        # Send the RPC command
        self.transport.rpc(spec.Confirm.Select(nowait),
                           self._on_confirm_select_ok, [spec.Confirm.SelectOk])
예제 #2
0
    def confirm_delivery(self, callback=None, nowait=False):
        """Turn on Confirm mode in the channel. Pass in a callback to be
        notified by the Broker when a message has been confirmed as received or
        rejected (Basic.Ack, Basic.Nack) from the broker to the publisher.

        For more information see:
            http://www.rabbitmq.com/extensions.html#confirms

        :param method callback: The callback for delivery confirmations
        :param bool nowait: Do not send a reply frame (Confirm.SelectOk)

        """
        self._validate_channel_and_callback(callback)
        if (self.connection.publisher_confirms is False or
            self.connection.basic_nack is False):
            raise exceptions.MethodNotImplemented('Not Supported on Server')

        # Add the ack and nack callbacks
        if callback is not None:
            self.callbacks.add(self.channel_number,
                               spec.Basic.Ack,
                               callback,
                               False)
            self.callbacks.add(self.channel_number,
                               spec.Basic.Nack,
                               callback,
                               False)

        # Send the RPC command
        self._rpc(spec.Confirm.Select(nowait),
                  self._on_selectok,
                  [spec.Confirm.SelectOk] if nowait is False else [])
예제 #3
0
    def confirm_delivery(self, nowait=False):
        self._validate_connection_and_channel()

        if not (self.connection.publisher_confirms
                and self.connection.basic_nack):
            raise exceptions.MethodNotImplemented('Not Supported on Server')
        self._delivery_confirmation = True
        return self.rpc(spec.Confirm.Select(nowait),
                        [spec.Confirm.SelectOk] if nowait is False else [])
예제 #4
0
    def confirm_delivery(self, nowait=False):
        """Turn on Confirm mode in the channel.

        For more information see:
            http://www.rabbitmq.com/extensions.html#confirms

        :param bool nowait: Do not send a reply frame (Confirm.SelectOk)

        """
        if (not self.connection.publisher_confirms
                or not self.connection.basic_nack):
            raise exceptions.MethodNotImplemented('Not Supported on Server')
        self._confirmation = True
        replies = [spec.Confirm.SelectOk] if nowait is False else []
        self._rpc(spec.Confirm.Select(nowait), None, replies)
        self.connection.process_data_events()