【发布时间】:2015-07-09 10:18:17
【问题描述】:
我正在尝试向 AMQP 发送请求,卡在如何向请求消息中添加标头,下面是我们拥有的包装器
$message = ‘{"empId": ‘.$empId.', “empName”:”my name"}’;
$resData = $rpcClient->call($message, self::EXCHANGE, self::ROUTING_KEY);
如何在上面的消息中添加标题
调用方法就是我们写的包装器
public function call($requestMessage, $exchange, $routingKey)
{
$this->response = null;
$this->correlationId = uniqid('abcprod', true);
$message = new AMQPMessage(
strval($requestMessage),
array('correlation_id' => $this->correlationId, 'reply_to' => $this->callbackQueue)
);
$this->channel
->basic_publish($message, $exchange, $routingKey);
try {
$this->channel->wait(null, false, self::REQUEST_TIMEOUT);
} catch (AMQPTimeoutException $e) {
return null;
}
return $this->response;
}
【问题讨论】:
标签: php amqp php-amqplib