rocketmq发送消息乱码
@Async
public SendResult send(String businessCode, String ms, String springTopic) throws Exception {
//生成message类型
Message<byte[]> message = MessageBuilder.withPayload(ms.getBytes(StandardCharsets.UTF_8)).build();
SendResult sendResult = rocketTemplate.syncSendOrderly(springTopic, message, springTopic);
log.info("{},mq send business_code: {}", springTopic, businessCode);
log.info("mq send message: {}", ms);
log.info("mq send result: {}", sendResult);
return sendResult;
}
直接发送json的字符串乱码,在windows上可以,但linux上就有问题了
解决方法:发送byte字节,接收方
ms.getBytes(StandardCharsets.UTF_8)