The docs say:
public bool AMQPExchange::publish ( string $message , string $routing_key开发者_StackOverflow社区 [, int $params = 0 [, array $attributes ]] )
So I have this
$this->exchange->publish(serialize($queue_message), $routing_key,AMQP_MANDATORY,array('delivery_mode' => '2'));
I'm trying to let the exchange KEEP TRYING to deliver the message?
You cannot tell the exchange to keep trying to deliver your message.
Normally, the recipient of a message will either auto-ack the message, or they will ack the message after successfully processing it. I recommend the second of these two choices. If a message is not acked then it will be requeued and if there is more than one subscriber to the queue, then it is possible that a different subscriber will process it.
My experience is all with topic exchanges (where you implement fanouts by having multiple queues that subscribe to the same routing_key. I always used delivery_mode 2 and also declared the queues as durable.
If the queue does not exist before messages are published, then they will silently disappear.
I suspect that your problem is with the string '2'
. Have you tried using the number 2
instead? Also it is a good idea to specify a content_type in the array as well. That would make it
$this->exchange->publish(serialize($queue_message),
$routing_key,AMQP_MANDATORY,array('delivery_mode' => 2,
'content_type' => 'text/json'));
精彩评论