注意:在Symfony2中通过RabbitMQBundle使用RabbitMq 。
我的制作人发送如下消息:
$message = array( 'class' => get_class($receiver), 'id' => $receiver->getId(), 'stepNumber' => 1, 'errorCount' => 0 );有没有办法在RabbitMQ重新排队之前修改$msg ?
Note: Using RabbitMq via RabbitMQBundle in Symfony2.
My producer sends a message like this :
$message = array( 'class' => get_class($receiver), 'id' => $receiver->getId(), 'stepNumber' => 1, 'errorCount' => 0 );Is there a way to modify the $msg before it is requeued by RabbitMQ?
最满意答案
正如这个答案所指出的那样,RabbitMQ不允许您在发布消息后更改消息。 当您返回false时,RabbitMQ只是将原始消息放回队列中进行处理。
通过使用所需的更改重新发布消息可以获得相同的效果,然后通过返回true来消耗原始消息。 您可能希望使用默认(无名称)交换重新发布消息,以便您可以将其直接发送到您从中获取原始消息的队列。
As this answer points out, RabbitMQ doesn't let you change messages after publishing them. When you return false, RabbitMQ just puts the original message back in the queue for processing.
It is possible to get the same effect by republishing the message with the changes you want, then consuming the original message by returning true. You will probably want to republish the message using the default (nameless) exchange so that you can send it directly to the queue that you got the original message from.
更多推荐
发布评论