开发者

Setting delivery mode for AMQP (RabbitMQ)

开发者 https://www.devze.com 2023-03-23 19:39 出处:网络
The docs say: public bool AMQPExchange::publish ( string $message , string $routing_key开发者_StackOverflow社区 [, int $params = 0 [, array $attributes ]] )

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'));
0

精彩评论

暂无评论...
验证码 换一张
取 消