提交 68d0cb45 作者: 方治民

chore: 调整 TestJob 示例

上级 045a5761
...@@ -8,8 +8,8 @@ import com.yiring.common.constant.DateFormatter; ...@@ -8,8 +8,8 @@ import com.yiring.common.constant.DateFormatter;
import com.yiring.common.core.Retriever; import com.yiring.common.core.Retriever;
import com.yiring.common.core.UptimeNotice; import com.yiring.common.core.UptimeNotice;
import com.yiring.common.exception.UptimeException; import com.yiring.common.exception.UptimeException;
import com.yiring.common.util.Uptime;
import com.yiring.common.util.XxlJobUtil; import com.yiring.common.util.XxlJobUtil;
import com.yiring.common.utils.Uptime;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Random; import java.util.Random;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -40,10 +40,10 @@ public class TestJob { ...@@ -40,10 +40,10 @@ public class TestJob {
retryCount = 3, retryCount = 3,
retryStatus = Uptime.Status.UP retryStatus = Uptime.Status.UP
) )
@Scheduled(fixedDelay = 5, timeUnit = TimeUnit.SECONDS) @Scheduled(fixedDelay = 5, timeUnit = TimeUnit.SECONDS, initialDelay = 5000)
public void testScheduled() { public void testScheduled() {
String time = LocalDateTime.now().format(DateFormatter.DATE_TIME); String time = LocalDateTime.now().format(DateFormatter.DATE_TIME);
log.info("TestJobHandler: {}", time); log.info("TestScheduled: {}", time);
Random random = new Random(); Random random = new Random();
int randomCount = random.nextInt(10); int randomCount = random.nextInt(10);
...@@ -53,12 +53,12 @@ public class TestJob { ...@@ -53,12 +53,12 @@ public class TestJob {
return "OK"; return "OK";
} }
throw new UptimeException("[TestJobHandler] test err: " + time); throw new UptimeException("[TestScheduled] test err: " + time);
}, },
Retriever::defaultPolicy Retriever::defaultPolicy
); );
log.info("[Test] result: {}", result); log.info("[TestScheduled] result: {}", result);
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
...@@ -68,9 +68,9 @@ public class TestJob { ...@@ -68,9 +68,9 @@ public class TestJob {
Random random = new Random(); Random random = new Random();
int randomCount = random.nextInt(10); int randomCount = random.nextInt(10);
if (randomCount < 5) { if (randomCount < 5) {
return XxlJobUtil.fail("TestNoticeHandler fail"); return XxlJobUtil.fail("fail");
} }
return XxlJobUtil.success("TestNoticeHandler success"); return XxlJobUtil.success("success");
} }
} }
...@@ -4,4 +4,5 @@ xxl: ...@@ -4,4 +4,5 @@ xxl:
enabled: true enabled: true
admin-addresses: http://192.168.0.156:8080/xxl-job-admin admin-addresses: http://192.168.0.156:8080/xxl-job-admin
access-token: local access-token: local
executor-app-name: xyh-app-preview executor-app-name: basic
executor-ip: 192.168.0.110
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论