✨ #654 quartz 配置使用Rest 调用

This commit is contained in:
冷冷 committed 2019-10-11 11:15:31 +08:00
1 parent 5cb53c3e3b
commit 9b916b9092
1 file changed
+6 -8
@@ -17,14 +17,12 @@
package com.pig4cloud.pigx.daemon.quartz.util;
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
import com.pig4cloud.pigx.common.core.util.R;
import cn.hutool.http.HttpUtil;
import com.pig4cloud.pigx.daemon.quartz.entity.SysJob;
import com.pig4cloud.pigx.daemon.quartz.exception.TaskException;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
/**
* 定时任务rest反射实现
@@ -32,16 +30,16 @@ import org.springframework.web.client.RestTemplate;
* @author 郑健楠
*/
@Slf4j
@Component("restTaskInvok")
@AllArgsConstructor
@Component("restTaskInvok")
public class RestTaskInvok implements ITaskInvok {
private RestTemplate restTemplate;
@Override
public void invokMethod(SysJob sysJob) throws TaskException {
R r = restTemplate.getForObject(sysJob.getExecutePath(), R.class);
if (CommonConstants.FAIL == r.getCode()) {
try {
HttpUtil.createGet(sysJob.getExecutePath())
.execute();
} catch (Exception e) {
log.error("定时任务restTaskInvok异常,执行任务:{}", sysJob.getExecutePath());
throw new TaskException("定时任务restTaskInvok业务执行失败,任务:" + sysJob.getExecutePath());
}