Pull request #51: RED-5009 pyinfra now truly rejects messages that couldn't be processed by the callback

Merge in RR/pyinfra from RED-5009-fix-ack-bug to master

Squashed commit of the following:

commit 7b00edf6fe1167345e774d658fcd2e60c01d05d5
Author: Julius Unverfehrt <julius.unverfehrt@iqser.com>
Date:   Wed Aug 24 14:52:57 2022 +0200

    RED-5009 pyinfra now truly rejects messages that couldn't be processed by the callback (e.g. inobtainable storage file)
This commit is contained in:
Julius Unverfehrt 2022-08-24 15:00:00 +02:00
parent 71ad2af4eb
commit 88b4c5c7ce

View File

@ -120,6 +120,7 @@ class QueueManager(object):
self.logger.info(f"Aborting message processing for delivery_tag {frame.delivery_tag} "
f"due to it being redelivered")
self._channel.basic_nack(frame.delivery_tag, requeue=False)
return
self.logger.debug(f"Processing {(frame, properties, body)}.")
try:
@ -138,6 +139,7 @@ class QueueManager(object):
self._channel.basic_ack(frame.delivery_tag)
else:
self.logger.info(f"Processed message with delivery_tag {frame.delivery_tag}, declining message")
self._channel.basic_nack(frame.delivery_tag, requeue=False)
except Exception as ex:
n_attempts = _get_n_previous_attempts(properties) + 1