我正在尝试向 AMQP 发送请求,卡在如何向请求消息中添加标头,下面是我们拥有的包装器
$message = ‘{"empId": ‘.$empId.', “empName”:”my name"}’;
$resData = $rpcClient->call($message, self::EXCHANGE, self::ROUTING_KEY);
如何在上述消息中添加标题
call 方法是我们编写的包装器
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;
}