我正在尝试将消息传递到交换器,然后传递到特定队列。
$conn = new AMQPConnection(RABBITMQ_NODE_IP_ADDRESS, RABBITMQ_PORT, RABBITMQ_USERNAME, RABBITMQ_PASSWORD, RABBITMQ_VHOST);
$queue = RABBITMQ_QUEUE_CSV;
$exchange = RABBITMQ_EXCHANGE;
$ch = $conn->channel();
$ch->exchange_declare($exchange, 'direct', false, true, false);
$ch->queue_declare($queue, false, true, false, false);
$ch->queue_bind($queue, $exchange, $queue);
$msg = new AMQPMessage(json_encode($params), array('content_type' => 'text/plain', 'delivery_mode' => 2));
$ch->basic_publish($msg, $exchange);
$ch->close();
$conn->close();
$status = Array("status" => "Job queued");
交换的类型是“直接”,然后我添加了一个名为“foo_bar”的队列,作为“路由键”,我使用了相同的“foo_bar”字符串。
只是阅读文档http://www.rabbitmq.com/tutorials/tutorial-four-php.html我不明白我在哪里做错了:(