This commit is contained in:
Leo
2024-12-01 15:30:15 +08:00
parent eb02d7f825
commit b73f1b0f52

View File

@@ -10,6 +10,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import static cn.van.business.util.WXUtil.WX_BASE_URL;
/**
@@ -29,8 +32,12 @@ public class MessageConsumerService implements RocketMQListener<JSONObject> {
// 处理消息
try {
logger.info("消费到消息:{}", jsonObject);
String body = jsonObject.getString("body");
byte[] decodedBody = Base64.getDecoder().decode(body);
String decodedBodyStr = new String(decodedBody, StandardCharsets.UTF_8);
JSONObject decodedBodyJson = JSONObject.parseObject(decodedBodyStr);
String responseStr = HttpRequest.post(WX_BASE_URL)
.body(JSONUtil.toJsonStr(jsonObject))
.body(JSONUtil.toJsonStr(decodedBodyJson))
.execute()
.body();