I have got a simple queueing system which, obviously, takes messages and publishes them.
However, due to a new development in the system, we now need to check for the x-death headers from the exchange, however, I can't seem any documentation on how to retrieve that through the PHP AMQP Library.
Anyone have any ideas on how to achieve this?
Check for it in application_headers property.
Here is a brief modified code from example:
/**
 * @param \PhpAmqpLib\Message\AMQPMessage $msg
 */
function process_message($msg)
{
    $headers = $msg->get('application_headers');
    $props = ['x-death'];
    // OR
    $props = $msg->get_properties();
    $props['application_headers']['x-death'];
    $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
}
$ch->basic_consume($queue, $consumer_tag, false, false, false, false, 'process_message');
                        Just to add some more to @pinepain's answer. You can do the following too:
/** @var AMQPMessage $message */
$props = $message->get_properties();
/** @var AMQPTable $applicationHeaders */
$applicationHeaders = $props['application_headers'];
$xdeath = $applicationHeaders->getNativeData()['x-death'];
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With