Azure / amqpnetlite

AMQP 1.0 .NET Library
Apache License 2.0
401 stars 143 forks source link

Question - Can a message be confirmed only by its delivery tag? #449

Closed Viktorstst closed 2 years ago

Viktorstst commented 3 years ago

I have a case where many messages have to be read and processed by a subsequent process, after which the successfully processed messages are confirmed as such to the broker. I found only receiver.Accept (message) as a method. Is there a way to do this only through the Delivery Tag of the message so that you do not have to keep messages in memory? For example, something like channel.BasicAck (deliveryTag, false).

Havret commented 3 years ago

Unfortunately it is not possible. Theoretically you don't need the full message object in order to send a disposition frame (according to AMQP 1.0 spec), but this is how it is implemented.

Viktorstst commented 3 years ago

Unfortunately it is not possible. Theoretically you don't need the full message object in order to send a disposition frame (according to AMQP 1.0 spec), but this is how it is implemented.

Ok. Thanks for the reply!

xinchen10 commented 3 years ago

Internally we need a few things in addition to delivery tag to manage the data structures. With just the delivery tag we would need to scan a linked list to find the delivery object. Also the message payload and its state are actually on the delivery object which is kept by the session before a delivery is settled. Dropping reference to a message object would not remove the data referenced by the delivery object.

One option is to add a MessagePointer class which will hold the minimal information in order to settle a delivery. Then you could process the message, call message.ToPointer(), and dispose the message. Later call receiver.Accept(messagePointer).