mbroadst / qamqp

AMQP 0.9.1 implementation for Qt
Other
151 stars 127 forks source link

src/qamqpexchange: add support for rejected/nacked deliveries #73

Open manner82 opened 6 years ago

manner82 commented 6 years ago

In case the queue has a message count/size limit (config "x-max-length"), rabbitmq can be configured to nack/reject publishing messages when the queue is full (config "x-overflow":"reject-publish").

In this setup, qamqp exchange only does a log and skips the nack message, which leads to these delivery tags are never removed from unconfirmedDeliveryTags vector, therefor allMessagesDelivered signal will never trigger.

To make the library user be able to handle this (but try to maintain compatibility), I have added an extra signal (messageDeliveryFinished) which is also sent when rejected/nacked messages remained, identifying the nacked messages by their delivery tags.

Also added direct signals for publish confirms / rejects, because handling nack/reject is often just a retry of the publish after some time. This requires storing the messages until they are confirmed. For some use cases keeping all messages in memory until there is a point when all waiting publishes gets confirmed is a waste of resources or not feasible at all (no time when all is confirmed).

See https://www.rabbitmq.com/maxlength.html and https://www.rabbitmq.com/confirms.html#server-sent-nacks