When publishing a message to RabbitMQ in PHP, the AMQPExchange->publish method returns true even if the exchange is not found. I am setting the AMQP_MANDATORY flag. Here is the code:
$myExchange->publish($myMessage, $myRoutingKey, AMQP_MANDATORY, $myOptions);
I know I am using the method in a valid way, since it works, but if I feed it a non-existent exchange or queue, it still returns true.
Mandatory, like immediate, doesn’t fail the publish action but instead returns the message, on the return channel of your AMQP client. So you need to check if messages have been returned to find out about issues with this mandatory publication.
Related: See this comment on
AMQPExchange::publish: http://www.php.net/manual/en/amqpexchange.publish.php#106987