parent
5128094594
commit
7bbb08b110
@ -0,0 +1,30 @@
|
||||
package com.example.easy.retry.job;
|
||||
|
||||
/**
|
||||
* @author zhengweilin
|
||||
* @version 1.0.0
|
||||
* @date 2024/01/22
|
||||
*/
|
||||
|
||||
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor;
|
||||
import com.aizuda.easy.retry.client.job.core.dto.JobArgs;
|
||||
import com.aizuda.easy.retry.client.model.ExecuteResult;
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.example.easy.retry.po.FailOrderPo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Component
|
||||
@JobExecutor(name = "testBroadcastJobExecutor")
|
||||
public class TestBroadcastJobExecutor {
|
||||
|
||||
public ExecuteResult jobExecute(JobArgs jobArgs) {
|
||||
if (new Random().nextInt(9) % 5 == 0) {
|
||||
throw new NullPointerException("广播节点抛异常了" + JsonUtil.toJsonString(jobArgs));
|
||||
}
|
||||
FailOrderPo failOrderPo = new FailOrderPo();
|
||||
failOrderPo.setOrderId("xiaowoniu");
|
||||
return ExecuteResult.success(failOrderPo);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.example.easy.retry.job;
|
||||
|
||||
/**
|
||||
* @author zhengweilin
|
||||
* @version 1.0.0
|
||||
* @date 2024/01/22
|
||||
*/
|
||||
|
||||
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor;
|
||||
import com.aizuda.easy.retry.client.job.core.dto.JobArgs;
|
||||
import com.aizuda.easy.retry.client.model.ExecuteResult;
|
||||
import com.example.easy.retry.po.FailOrderPo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@JobExecutor(name = "testPartitionJobExecutor")
|
||||
public class TestPartitionJobExecutor {
|
||||
|
||||
public ExecuteResult jobExecute(JobArgs jobArgs) {
|
||||
if (jobArgs.getArgsStr().equals("1")) {
|
||||
throw new NullPointerException("分区空指针抛异常了");
|
||||
}
|
||||
FailOrderPo failOrderPo = new FailOrderPo();
|
||||
failOrderPo.setOrderId("xiaowoniu");
|
||||
return ExecuteResult.success(failOrderPo);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package com.example.easy.retry.job;
|
||||
import com.aizuda.easy.retry.client.job.core.annotation.JobExecutor;
|
||||
import com.aizuda.easy.retry.client.job.core.dto.JobArgs;
|
||||
import com.aizuda.easy.retry.client.model.ExecuteResult;
|
||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.example.easy.retry.po.FailOrderPo;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -16,11 +17,13 @@ import org.springframework.stereotype.Component;
|
||||
@JobExecutor(name = "testWorkflowAnnoJobExecutor")
|
||||
public class TestWorkflowAnnoJobExecutor {
|
||||
|
||||
public ExecuteResult jobExecute(JobArgs jobArgs) {
|
||||
EasyRetryLog.REMOTE.info("任务执行开始. [{}]", jobArgs);
|
||||
public ExecuteResult jobExecute(JobArgs jobArgs) throws InterruptedException {
|
||||
for (int i = 0; i < 30; i++) {
|
||||
EasyRetryLog.REMOTE.info("任务执行开始. [{}]", i + "" + JsonUtil.toJsonString(jobArgs));
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
FailOrderPo failOrderPo = new FailOrderPo();
|
||||
failOrderPo.setOrderId("xiaowoniu");
|
||||
EasyRetryLog.REMOTE.info("任务执行结束. [{}]", jobArgs);
|
||||
return ExecuteResult.success(failOrderPo);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user