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