RabbitMQ: basic_ack 是否也需要服务器确认?
RabbitMQ: does basic_ack also needs to be confirmed by the server?
假设我使用“confirm.select”将一个通道置于确认模式,并将确认模式设置为手动,然后我执行以下操作(伪代码):
function msg_handler(msg: TheDelivery, chan: TheChannelThatDeliverredThisMessage) {
let new_msg = do_some_computation(msg)
let confirm = chan.basic_publish(some_other_queue, new_msg)
-- wait for rabbitmq to confirm this new_msg
confirm.wait_for_rmq_confirmation()
let x = chan.basic_ack(msg.delivery_tag)
-- Question: do I need x.wait_for_rmq_confirmation() here?
-- namely, does the basic_ack/reject/nack needs to be confirmed
-- if the channel is in confirmation mode?
-- The library I am using doesn't require the ack to be confirmed,
-- for the basic_ack call returns unit, so there is no handle to wait on,
-- I just want to know that this is the way the AMQP designed (no confirms
-- of the ack are generated by the rmq server), or that, the protocol requires
-- that the confirmation of the channel.basic_ack should be generated by the server,
-- it's just that the library I am using that hides this from me (when the channel is
-- in confirmation mode)
}
channel.basic_consume(some_queue_name, msg_handler).wait_forever()
否,basic.ack
不需要确认。如果确认消息出现问题(例如,它在网络上丢失),RabbitMQ 会将消息保持在“Unacked”状态。当与该消息关联的通道关闭时,RabbitMQ 将 re-enqueue 它并将其传递给该队列的下一个消费者。
请注意,这意味着消息 将被传递两次! 这是您必须考虑的情况(很少见,但可能发生)。
注意: RabbitMQ 团队监控 rabbitmq-users
mailing list 并且有时只在 Whosebug 上回答问题。
假设我使用“confirm.select”将一个通道置于确认模式,并将确认模式设置为手动,然后我执行以下操作(伪代码):
function msg_handler(msg: TheDelivery, chan: TheChannelThatDeliverredThisMessage) {
let new_msg = do_some_computation(msg)
let confirm = chan.basic_publish(some_other_queue, new_msg)
-- wait for rabbitmq to confirm this new_msg
confirm.wait_for_rmq_confirmation()
let x = chan.basic_ack(msg.delivery_tag)
-- Question: do I need x.wait_for_rmq_confirmation() here?
-- namely, does the basic_ack/reject/nack needs to be confirmed
-- if the channel is in confirmation mode?
-- The library I am using doesn't require the ack to be confirmed,
-- for the basic_ack call returns unit, so there is no handle to wait on,
-- I just want to know that this is the way the AMQP designed (no confirms
-- of the ack are generated by the rmq server), or that, the protocol requires
-- that the confirmation of the channel.basic_ack should be generated by the server,
-- it's just that the library I am using that hides this from me (when the channel is
-- in confirmation mode)
}
channel.basic_consume(some_queue_name, msg_handler).wait_forever()
否,basic.ack
不需要确认。如果确认消息出现问题(例如,它在网络上丢失),RabbitMQ 会将消息保持在“Unacked”状态。当与该消息关联的通道关闭时,RabbitMQ 将 re-enqueue 它并将其传递给该队列的下一个消费者。
请注意,这意味着消息 将被传递两次! 这是您必须考虑的情况(很少见,但可能发生)。
注意: RabbitMQ 团队监控 rabbitmq-users
mailing list 并且有时只在 Whosebug 上回答问题。