pika向nack响应添加标题

2024-09-29 01:28:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在修改pika标题使用

properties.headers = {
     'myheader': myheader
}

但我正在和delivery_tag交流

channel.basic_nack(delivery_tag=delivery_tag, requeue=False)

如何将带有标头的更新属性传递给ack和nack响应函数?或者皮卡是怎么做的?你知道吗


Tags: false标题属性basictagchannelproperties交流
2条回答

来自pika docs的摘录说,你拼写错了basic_nck。。。只是一个问题错误还是你的实际问题?你知道吗

ef basic_nack(self, delivery_tag=None, multiple=False, requeue=True):
        """This method allows a client to reject one or more incoming messages.
        It can be used to interrupt and cancel large incoming messages, or
        return untreatable messages to their original queue.

        :param integer delivery-tag: int/long The server-assigned delivery tag
        :param bool multiple: If set to True, the delivery tag is treated as
                              "up to and including", so that multiple messages
                              can be acknowledged with a single method. If set
                              to False, the delivery tag refers to a single
                              message. If the multiple field is 1, and the
                              delivery tag is zero, this indicates
                              acknowledgement of all outstanding messages.
        :param bool requeue: If requeue is true, the server will attempt to
                             requeue the message. If requeue is false or the
                             requeue attempt fails the messages are discarded or
                             dead-lettered.

        """
        self._raise_if_not_open()
        return self._send_method(
            spec.Basic.Nack(delivery_tag, multiple, requeue))

很抱歉,但据我所知,是不可能的基本确认(或基本确认)修改标题。问题是“modified”消息将被放入死信队列,而新消息的ID较新

我-

basic_nack不能更改头是正确的。你知道吗

实现这一点的方法根本不是使用NACK,而是生成并返回一个“new”消息(这只是您正在处理的当前消息,但是向其中添加了新的头)。你知道吗

根据AMQP规范,NACK基本上是这样做的

所以我的逻辑是在成功时使用basic_ack,在失败时使用更新的消息头生成消息。在我的例子中,我将新消息“重定向”到死信队列绑定到的死信交换。你知道吗

相关问题 更多 >