Rabbitmq RPC請求報出rabbitmq no correlation header in reply
問題說明
在springboot中使用rabbitTemplate.convertSendAndReceive方法發送rpc請求,報出rabbitmq no correlation header in reply錯誤
問題原因
server端沒有取出請求資訊correlation_id,并存入傳回資訊中,導緻rpc傳回資訊中沒有 correlation_id
解決辦法
server端擷取請求資訊的correlation_id,并存入傳回資訊
amqpTemplate.convertAndSend(replyTo, (Object) result, new MessagePostProcessor(){
@Override
public Message postProcessMessage(Message message) {
message.getMessageProperties().setCorrelationId(correlationId);
return message;
}