定时任务-礼物-mq-并行补偿

This commit is contained in:
khalil
2024-10-19 19:12:13 +08:00
parent 5645c2c3e4
commit 315cd6f8f2

View File

@@ -29,13 +29,13 @@ public class GiftTask extends BaseTask {
if (map == null || map.size() == 0) {
return;
}
Set<String> keySet = map.keySet();
long curTime = System.currentTimeMillis();
long gapTime = 1000 * 60 * 10; // 十分钟内没被消费
for (String key : keySet) {
map.entrySet().parallelStream().forEach(entry -> {
try {
String val = map.get(key);
String messId = entry.getKey();
String val = entry.getValue();
GiftMessage giftMessage = gson.fromJson(val, GiftMessage.class);
if (curTime - giftMessage.getMessTime() > gapTime) {
giftMessageService.handleGiftMessage(giftMessage);
@@ -43,7 +43,7 @@ public class GiftTask extends BaseTask {
} catch (Exception e) {
log.error("retryGiftQueue error", e);
}
}
});
log.info("retryGiftQueue end ...");
}