Commit 955b709710d16934612930416b7d4315dc0981b9
1 parent
f3db296c
修复启动报错
Showing
2 changed files
with
37 additions
and
13 deletions
src/main/java/com/diligrp/rider/service/impl/WebhookServiceImpl.java
| @@ -13,7 +13,6 @@ import com.diligrp.rider.util.SignUtil; | @@ -13,7 +13,6 @@ import com.diligrp.rider.util.SignUtil; | ||
| 13 | import lombok.RequiredArgsConstructor; | 13 | import lombok.RequiredArgsConstructor; |
| 14 | import lombok.extern.slf4j.Slf4j; | 14 | import lombok.extern.slf4j.Slf4j; |
| 15 | import org.springframework.scheduling.annotation.Async; | 15 | import org.springframework.scheduling.annotation.Async; |
| 16 | -import org.springframework.scheduling.annotation.Scheduled; | ||
| 17 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| 18 | 17 | ||
| 19 | import java.net.URI; | 18 | import java.net.URI; |
| @@ -76,18 +75,6 @@ public class WebhookServiceImpl implements WebhookService { | @@ -76,18 +75,6 @@ public class WebhookServiceImpl implements WebhookService { | ||
| 76 | retry(log); | 75 | retry(log); |
| 77 | } | 76 | } |
| 78 | 77 | ||
| 79 | - @Scheduled(fixedDelay = 300_000) | ||
| 80 | - public void retryFailedWebhooks() { | ||
| 81 | - List<WebhookLog> logs = webhookLogMapper.selectList(new LambdaQueryWrapper<WebhookLog>() | ||
| 82 | - .eq(WebhookLog::getStatus, 0) | ||
| 83 | - .lt(WebhookLog::getRetryCount, 5) | ||
| 84 | - .orderByAsc(WebhookLog::getCreateTime) | ||
| 85 | - .last("LIMIT 20")); | ||
| 86 | - for (WebhookLog log : logs) { | ||
| 87 | - retry(log); | ||
| 88 | - } | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | private void retry(WebhookLog webhookLog) { | 78 | private void retry(WebhookLog webhookLog) { |
| 92 | OpenApp app = openAppMapper.selectById(webhookLog.getAppId()); | 79 | OpenApp app = openAppMapper.selectById(webhookLog.getAppId()); |
| 93 | if (app == null) return; | 80 | if (app == null) return; |
src/main/java/com/diligrp/rider/task/WebhookRetryTask.java
0 → 100644
| 1 | +package com.diligrp.rider.task; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 4 | +import com.diligrp.rider.entity.WebhookLog; | ||
| 5 | +import com.diligrp.rider.mapper.WebhookLogMapper; | ||
| 6 | +import com.diligrp.rider.service.WebhookService; | ||
| 7 | +import lombok.RequiredArgsConstructor; | ||
| 8 | +import lombok.extern.slf4j.Slf4j; | ||
| 9 | +import org.springframework.scheduling.annotation.Scheduled; | ||
| 10 | +import org.springframework.stereotype.Component; | ||
| 11 | + | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +@Slf4j | ||
| 15 | +@Component | ||
| 16 | +@RequiredArgsConstructor | ||
| 17 | +public class WebhookRetryTask { | ||
| 18 | + | ||
| 19 | + private final WebhookLogMapper webhookLogMapper; | ||
| 20 | + private final WebhookService webhookService; | ||
| 21 | + | ||
| 22 | + @Scheduled(fixedDelay = 300_000) | ||
| 23 | + public void retryFailedWebhooks() { | ||
| 24 | + List<WebhookLog> logs = webhookLogMapper.selectList(new LambdaQueryWrapper<WebhookLog>() | ||
| 25 | + .eq(WebhookLog::getStatus, 0) | ||
| 26 | + .lt(WebhookLog::getRetryCount, 5) | ||
| 27 | + .orderByAsc(WebhookLog::getCreateTime) | ||
| 28 | + .last("LIMIT 20")); | ||
| 29 | + for (WebhookLog webhookLog : logs) { | ||
| 30 | + try { | ||
| 31 | + webhookService.retry(webhookLog.getId()); | ||
| 32 | + } catch (Exception e) { | ||
| 33 | + log.warn("Webhook 自动重试失败 logId={}", webhookLog.getId(), e); | ||
| 34 | + } | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | +} |