I'm using Pika/RabbitMQ lib for processing messages in a python 3.8 project. When processing the messages the function can fail due to several reasons. There are a few cases when the message can be recovered in part if modified. I'm currently creating a new message with the modified body and queuing it. This is not ideal since the processor is the one re-queuing a message that it did not send.
I'm wondering if there's a way to modify the original message body and send a basic_nack
in order to re-queue a modified message to be processed again. In this way I don't have to recreate the message broker and message sender.
I'm wondering if there's a way to modify the original message body and send a basic_nack in order to re-queue a modified message to be processed again
No this is not possible with any AMQP broker. Creating a new message with the modified body and publishing it is the correct action to take.