Is it possible to alter the message headers of an AMQPMessage in a PHP consumer?

I am using Symfony 2 and the videlalvaro/RabbitMqBundle to push messages to a queue post event-firing in Symfony.

The queue itself is all working fine and the messages are looking perfect on the queue.

I’m aware that it’s not possible to change the content of a message in the AMQP spec, but is it possible to add or alter message headers at all, and if so, would anyone know how that’s accomplished please?

Essentially, I’m attempting to gracefully implement a ‘max retries’ concept. Previously I’ve ‘acked’ the message and queued up an identical one to the same queue, only with a now-incremented ‘# of attempts’ field. This is fine, and it works, but it feels very messy, which is what inspired the question.

TL;DR is there any way of updating a message before requeueing, and are headers the best way to go about it?

Thank you very much in advance!


Source: php

Leave a Reply