1
This commit is contained in:
@@ -45,18 +45,19 @@ public class MessageConsumerService implements RocketMQListener<JSONObject> {
|
||||
// 处理消息
|
||||
try {
|
||||
rateLimiter.acquire(); // 请求许可。如果超过速率,则此方法会阻塞
|
||||
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 jsonStr = JSONUtil.toJsonStr(decodedBodyJson);
|
||||
String responseStr = HttpRequest.post(WX_BASE_URL)
|
||||
.body(JSONUtil.toJsonStr(decodedBodyJson))
|
||||
.body(jsonStr)
|
||||
.execute()
|
||||
.body();
|
||||
|
||||
logger.info("消费消息:{}", jsonStr);
|
||||
if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||
JSONObject response = JSONObject.parseObject(responseStr);
|
||||
logger.info("消息成功发送并得到响应:{}", response);
|
||||
if (response.getInteger("code") != 200) {
|
||||
// TODO: 如果需要处理错误,您可以在这里添加逻辑
|
||||
wxtsUtil.sendNotify("消息发送失败: " + responseStr);
|
||||
|
||||
Reference in New Issue
Block a user