What is the difference between Delivery.Ack and Channel.Ack in go's RabbitMQ?

in RabbitMQ"s go support library, there are two methods
func (ch * Channel) Ack (tag uint64, multiple bool) error and func (d Delivery) Ack (multiple bool) error
but do not understand the difference between these two methods?
the description of the two methods is as follows:

Channel.Ack

Ack acknowledges a delivery by its delivery tag when having been consumed with Channel.Consume or Channel.Get.

Ack acknowledges all message received prior to the delivery tag when multiple is true.

See also Delivery.Ack

Delivery.Ack

Ack delegates an acknowledgement through the Acknowledger interface that the client or server has finished work on a delivery.

All deliveries in AMQP must be acknowledged. If you called Channel.Consume with autoAck true then the server will be automatically ack each message and this method should not be called. Otherwise, you must call Delivery.Ack after you have successfully processed this delivery.

When multiple is true, this delivery and all prior unacknowledged deliveries on the same channel will be acknowledged. This is useful for batch processing of deliveries.

An error will indicate that the acknowledge could not be delivered to the channel it was sent from.

Either Delivery.Ack, Delivery.Reject or Delivery.Nack must be called for every delivery that is not automatically acknowledged.

AMQP Library description

Mar.30,2021

there are three Ack in the AMQP library

  1. Acknowledger.Ack
  2. Channel.Ack
  3. Delivery.Ack

looking at the source code, it is found that Acknowledger is an interface with three methods Ack , Nack , and Reject . Channel implements this interface
Delivery, which has a member variable of Acknowledger type, so Delivery can also call this method

.

so:

  • Acknowledger is the interface
  • Channel is the concrete implementation
  • Delivery is a concrete instance (object)
Menu