我正试图向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;
}