提交 b68ca59c 作者: 方治民

chore: 调整日志输出,注释 TestJob @Scheduled

上级 8d20c5b5
......@@ -4,60 +4,54 @@ package com.yiring.app.job;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.yiring.common.annotation.UptimePush;
import com.yiring.common.constant.DateFormatter;
import com.yiring.common.core.Retriever;
import com.yiring.common.core.UptimeNotice;
import com.yiring.common.exception.UptimeException;
import com.yiring.common.util.XxlJobUtil;
import com.yiring.common.utils.Uptime;
import java.time.LocalDateTime;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* @author Jim
*/
@SuppressWarnings("unused")
@Slf4j
@Component
@RequiredArgsConstructor
public class TestJob {
final Retriever retriever;
/**
* 一个使用 Retriever + @UptimePush 双链路重试的定时任务示例
*/
@UptimePush(
key = "BiCC4Jgoa5",
group = "Test",
name = "[TestScheduled] 测试任务调度",
retryCount = 3,
retryStatus = Uptime.Status.UP
)
@Scheduled(fixedDelay = 5, timeUnit = TimeUnit.SECONDS, initialDelay = 60)
public void testScheduled() {
String time = LocalDateTime.now().format(DateFormatter.DATE_TIME);
log.info("TestScheduled: {}", time);
Random random = new Random();
int randomCount = random.nextInt(10);
String result = retriever.execute(
ctx -> {
if (ctx.getRetryCount() > randomCount) {
return "OK";
}
throw new UptimeException("[TestScheduled] test err: " + time);
},
Retriever::defaultPolicy
);
log.info("[TestScheduled] result: {}", result);
}
// final Retriever retriever;
//
// /**
// * 一个使用 Retriever + @UptimePush 双链路重试的定时任务示例
// */
// @UptimePush(
// key = "BiCC4Jgoa5",
// group = "Test",
// name = "[TestScheduled] 测试任务调度",
// retryCount = 3,
// retryStatus = Uptime.Status.UP
// )
// @Scheduled(fixedDelay = 5, timeUnit = TimeUnit.SECONDS, initialDelay = 60)
// public void testScheduled() {
// String time = LocalDateTime.now().format(DateFormatter.DATE_TIME);
// log.info("TestScheduled: {}", time);
//
// Random random = new Random();
// int randomCount = random.nextInt(10);
// String result = retriever.execute(
// ctx -> {
// if (ctx.getRetryCount() > randomCount) {
// return "OK";
// }
//
// throw new UptimeException("[TestScheduled] test err: " + time);
// },
// Retriever::defaultPolicy
// );
//
// log.info("[TestScheduled] result: {}", result);
// }
@SuppressWarnings("unused")
@UptimePush(key = "BiCC4Jgoa5", group = "Test", name = "[TestNoticeHandler] 测试任务调度")
......
......@@ -32,3 +32,7 @@ logging:
org.springframework.core.LocalVariableTableParameterNameDiscoverer: ERROR
# loki filter logger
pl.piomin.logging.filter.SpringLoggingFilter: WARN
# 关闭 jasypt 日志
com.ulisesbocchio: WARN
# 关闭 hibernate 连接池日志
org.hibernate.orm.connections.pooling: WARN
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论