dpiz9879 2014-07-24 14:30
浏览 283
已采纳

RabbitMQ PHP AMQP库 - 获取消息头

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?

  • 写回答

2条回答 默认 最新

  • duancao1951 2014-07-24 16:18
    关注

    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');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?