| | |
| | | |
| | | @Scheduled(cron = "0/30 * * * * ?") |
| | | public void syncCloudWmsNotify() { |
| | | List<CloudWmsNotifyLog> pending = cloudWmsNotifyLogService.listPending(BATCH_LIMIT, 999); |
| | | // List<CloudWmsNotifyLog> pending = cloudWmsNotifyLogService.listPending(BATCH_LIMIT, 999); |
| | | List<CloudWmsNotifyLog> pending = cloudWmsNotifyLogService.listPending(BATCH_LIMIT, -1); |
| | | if (pending.isEmpty()) { |
| | | return; |
| | | } |
| | |
| | | if (maxRetry == null || intervalSeconds == null || intervalSeconds <= 0) { |
| | | continue; |
| | | } |
| | | if (logRecord.getRetryCount() != null && logRecord.getRetryCount() >= maxRetry) { |
| | | // if (logRecord.getRetryCount() != null && logRecord.getRetryCount() >= maxRetry) { |
| | | if (!isInfiniteRetry(maxRetry) |
| | | && logRecord.getRetryCount() != null |
| | | && logRecord.getRetryCount() >= maxRetry) { |
| | | continue; |
| | | } |
| | | if (logRecord.getLastNotifyTime() != null) { |
| | |
| | | Object codeObj = res != null ? res.get("code") : null; |
| | | boolean success = Integer.valueOf(200).equals(codeObj); |
| | | int status = success ? cloudWmsNotifyLogService.getNotifyStatusSuccess() : cloudWmsNotifyLogService.getNotifyStatusPending(); |
| | | if (!success && nextRetry >= effectiveMaxRetry) { |
| | | if (!success && !isInfiniteRetry(effectiveMaxRetry) && nextRetry >= effectiveMaxRetry) { |
| | | status = cloudWmsNotifyLogService.getNotifyStatusFail(); |
| | | } |
| | | logRecord.setLastRequestBody(requestBody); |
| | |
| | | logRecord.setLastResponseBody(errorMsg); |
| | | logRecord.setLastNotifyTime(now); |
| | | logRecord.setRetryCount(nextRetry); |
| | | logRecord.setNotifyStatus(nextRetry >= effectiveMaxRetry ? cloudWmsNotifyLogService.getNotifyStatusFail() : cloudWmsNotifyLogService.getNotifyStatusPending()); |
| | | // logRecord.setNotifyStatus(nextRetry >= effectiveMaxRetry ? cloudWmsNotifyLogService.getNotifyStatusFail() : cloudWmsNotifyLogService.getNotifyStatusPending()); |
| | | logRecord.setNotifyStatus(!isInfiniteRetry(effectiveMaxRetry) && nextRetry >= effectiveMaxRetry |
| | | ? cloudWmsNotifyLogService.getNotifyStatusFail() |
| | | : cloudWmsNotifyLogService.getNotifyStatusPending()); |
| | | logRecord.setUpdateTime(now); |
| | | cloudWmsNotifyLogService.updateById(logRecord); |
| | | } |
| | | |
| | | /** maxRetry = -1 表示无限重发 */ |
| | | private boolean isInfiniteRetry(Integer maxRetry) { |
| | | return maxRetry != null && maxRetry == -1; |
| | | } |
| | | } |