xxl-job主要分为调度中心和执行器提供了图像化界面,操作简单上手快,基本实现定时任务自动执行,同时可以针对任务日志进行查看。具体xxl-job可以再github上下载:https://github.com/xuxueli/xxl-job。
本文主要描述xxl-job的接口调用
pom.xml引入

  1. <!--针对自己项目的xxl-job-core进行引入即可-->
  2. <dependency>
  3. <groupId>com.test</groupId>
  4. <artifactId>xxl-job-core</artifactId>
  5. <version>1.0-SNAPSHOT</version>
  6. </dependency>
  7. <!--org.apache.commons.httpclient-->
  8. <dependency>
  9. <groupId>commons-httpclient</groupId>
  10. <artifactId>commons-httpclient</artifactId>
  11. <version>3.1</version>
  12. </dependency>

application.yml配置信息

  1. xxl:
  2. job:
  3. admin:
  4. # xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
  5. # xxl-job-admin 启动地址
  6. addresses: http://192.168.1.59:7000/xxl-job-admin
  7. # xxl-job, access token
  8. accessToken:
  9. executor:
  10. # xxl-job executor appname 手动配置的客户端名称
  11. appname: xxl-job-executor-test
  12. # xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null
  13. address:
  14. # xxl-job executor server-info 可以自动分配地址进行注册
  15. ip:
  16. port: 9985
  17. # xxl-job executor log-path
  18. logpath: logs/applogs/xxl-job/jobhandler
  19. # xxl-job executor log-retention-days
  20. logretentiondays: 30

controller层代码

  1. package com.controller;
  2.  
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.util.TimeUtil;
  5. import com.util.results.Resp;
  6. import com.hywx.gw.loadservice.util.XxlJobUtil;
  7. import io.swagger.annotations.ApiOperation;
  8. import org.apache.commons.lang.StringUtils;
  9. import org.slf4j.Logger;
  10. import org.slf4j.LoggerFactory;
  11. import org.springframework.beans.factory.annotation.Value;
  12. import org.springframework.web.bind.annotation.GetMapping;
  13. import org.springframework.web.bind.annotation.RequestMapping;
  14. import org.springframework.web.bind.annotation.RequestMethod;
  15. import org.springframework.web.bind.annotation.RestController;
  16.  
  17. import java.io.IOException;
  18. import java.util.Date;
  19.  
  20. /**
  21. * @ClassName: TestSaveXxlController
  22. * @Description:
  23. * @Author LXYuuuuu
  24. * @Date 2020/6/29 15:38
  25. */
  26. @RestController
  27. @RequestMapping("/Test")
  28. public class TestXxlJobController {
  29. private static final Logger LOGGER = LoggerFactory.getLogger(TestXxlJobController.class);
  30. @Value("${xxl.job.admin.addresses}")
  31. private String adminAddresses;
  32. @Value("${xxl.job.executor.appname}")
  33. private String executorAppname;
  34.  
  35. @ApiOperation(value = "添加jobInfo并启动", httpMethod = "GET")
  36. @GetMapping
  37. public Resp saveXxl() {
  38. //查询列表数据
  39. try {
  40. JSONObject requestInfo = new JSONObject();
  41. // 执行器主键ID
  42. requestInfo.put("jobGroup", 2);
  43. // 任务执行CRON表达式
  44. long etime1 = System.currentTimeMillis() + 1 * 60 * 1000;//延时函数,单位毫秒,这里是延时了1分钟
  45. String date = TimeUtil.getCron(new Date(etime1));
  46. System.out.println(date);
  47. // requestInfo.put("jobCron","0 0/1 * * * ?");
  48. requestInfo.put("jobCron", date);
  49. // 任务描述
  50. requestInfo.put("jobDesc", "xxxJob");
  51.  
  52. // 负责人
  53. requestInfo.put("author", "admin");
  54. // 报警邮件
  55. requestInfo.put("alarmEmail", "xxx@satcloud.com.cn");
  56.  
  57. // 执行器路由策略
  58. requestInfo.put("executorRouteStrategy", "FIRST");
  59. // 执行器,任务Handler名称
  60. requestInfo.put("executorHandler", "xxxJobHandler");
  61. // todo 执行器,任务参数
  62. requestInfo.put("executorParam", "测试202006300943");
  63. // 阻塞处理策略
  64. requestInfo.put("executorBlockStrategy", "SERIAL_EXECUTION");
  65. // 任务执行超时时间,单位秒
  66. requestInfo.put("executorTimeout", 0);
  67. // 失败重试次数
  68. requestInfo.put("executorFailRetryCount", 1);
  69. // GLUE类型 #com.xxl.job.core.glue.GlueTypeEnum
  70. requestInfo.put("glueType", "BEAN");
  71. // GLUE备注
  72. requestInfo.put("glueRemark", "GLUE代码初始化");
  73.  
  74. // 调度状态:0-停止,1-运行
  75. requestInfo.put("triggerStatus", 0);
  76. // 上次调度时间
  77. requestInfo.put("triggerLastTime", 0);
  78. // 下次调度时间
  79. requestInfo.put("triggerNextTime", 0);
  80. // requestInfo.put("cronGen_display","0 0/1 * * * ?");
  81. JSONObject response = XxlJobUtil.addJob(adminAddresses, requestInfo);
  82. if (response.containsKey("code") && 200 == (Integer) response.get("code")) {
  83. //修改任务参数 把id放入
  84. // 执行器主键ID
  85. requestInfo.put("executorParam", "JobId=" + response.get("content") + ";测试202006300943");
  86. requestInfo.put("id", Integer.valueOf(response.get("content").toString()));
  87. JSONObject responseUpdate = XxlJobUtil.updateJob(adminAddresses, requestInfo);
  88. if (responseUpdate.containsKey("code") && 200 == (Integer) responseUpdate.get("code")) {
  89. //加入任务成功之后直接启动
  90. JSONObject responseStart = XxlJobUtil.startJob(adminAddresses, Integer.valueOf(response.get("content").toString()));
  91. if (responseStart.containsKey("code") && 200 == (Integer) responseStart.get("code")) {
  92. return Resp.getInstantiationSuccess("成功", null, null);
  93. } else {
  94. throw new Exception("调用xxl-job-admin-start接口失败!");
  95. }
  96. } else {
  97. throw new Exception("调用xxl-job-admin-update接口失败!");
  98. }
  99. } else {
  100. throw new Exception("调用xxl-job-admin-add接口失败!");
  101. }
  102. } catch (Exception e) {
  103. return Resp.getInstantiationError("失败" + e.getMessage(), null, null);
  104. }
  105. }
  106.  
  107. /**
  108. * 删除任务
  109. *
  110. * @param id
  111. * @return
  112. * @throws IOException
  113. */
  114. @RequestMapping(value = "/delete", method = RequestMethod.GET)
  115. public Resp delete(int id) {
  116. try {
  117. JSONObject response = XxlJobUtil.deleteJob(adminAddresses, id);
  118. if (response.containsKey("code") && 200 == (Integer) response.get("code")) {
  119. return Resp.getInstantiationSuccess("成功", null, null);
  120. } else {
  121. throw new Exception("调用xxl-job-admin-delete接口失败!");
  122. }
  123. } catch (Exception e) {
  124. return Resp.getInstantiationError("失败" + e.getMessage(), null, null);
  125. }
  126.  
  127. }
  128.  
  129. /**
  130. * 开始任务
  131. *
  132. * @param id
  133. * @return
  134. * @throws IOException
  135. */
  136. @RequestMapping(value = "/start", method = RequestMethod.GET)
  137. public Resp start(int id) {
  138. try {
  139. JSONObject response = XxlJobUtil.startJob(adminAddresses, id);
  140. if (response.containsKey("code") && 200 == (Integer) response.get("code")) {
  141. return Resp.getInstantiationSuccess("成功", null, null);
  142. } else {
  143. throw new Exception("调用xxl-job-admin-start接口失败!");
  144. }
  145. } catch (Exception e) {
  146. return Resp.getInstantiationError("失败" + e.getMessage(), null, null);
  147. }
  148.  
  149. }
  150.  
  151. /**
  152. * 挂起任务
  153. *
  154. * @param id
  155. * @return
  156. * @throws IOException
  157. */
  158. @RequestMapping(value = "/stop", method = RequestMethod.GET)
  159. public Resp stop(int id) {
  160. try {
  161. JSONObject response = XxlJobUtil.stopJob(adminAddresses, id);
  162. if (response.containsKey("code") && 200 == (Integer) response.get("code")) {
  163. return Resp.getInstantiationSuccess("成功", null, null);
  164. } else {
  165. throw new Exception("调用xxl-job-admin-stop接口失败!");
  166. }
  167. } catch (Exception e) {
  168. return Resp.getInstantiationError("失败" + e.getMessage(), null, null);
  169. }
  170. }
  171.  
  172. /**
  173. * 登陆
  174. *
  175. * @param userName
  176. * @param password
  177. * @return
  178. * @throws IOException
  179. */
  180. @RequestMapping(value = "/login", method = RequestMethod.GET)
  181. public Resp login(String userName, String password) {
  182. try {
  183. String cookie = XxlJobUtil.login(adminAddresses, userName, password);
  184. if (StringUtils.isNotBlank(cookie)) {
  185. return Resp.getInstantiationSuccess("成功", null, null);
  186. } else {
  187. throw new Exception("调用xxl-job-admin-login接口失败!");
  188. }
  189. } catch (Exception e) {
  190. return Resp.getInstantiationError("失败" + e.getMessage(), null, null);
  191. }
  192. }
  193. /**
  194. * 根据xxl-appname获取对应id
  195. *
  196. * @return
  197. * @throws IOException
  198. */
  199. @RequestMapping(value = "/getAppNameIdByAppname", method = RequestMethod.GET)
  200. public Resp getAppNameIdByAppname() {
  201. try {
  202. JSONObject response = XxlJobUtil.getAppNameIdByAppname(adminAddresses,executorAppname);
  203. if (response.containsKey("code") && 200 == (Integer) response.get("code")) {
  204. return Resp.getInstantiationSuccess("成功", null, null);
  205. } else {
  206. throw new Exception("调用xxl-job-admin-getAppNameIdByAppname接口失败!");
  207. }
  208. } catch (Exception e) {
  209. return Resp.getInstantiationError("失败" + e.getMessage(), null, null);
  210. }
  211. }
  212. }

XxlJobUtil 工具类

  1. package com.util;
  2.  
  3. import com.alibaba.fastjson.JSONObject;
  4. import org.apache.commons.httpclient.Cookie;
  5. import org.apache.commons.httpclient.HttpClient;
  6. import org.apache.commons.httpclient.HttpException;
  7. import org.apache.commons.httpclient.HttpMethod;
  8. import org.apache.commons.httpclient.methods.GetMethod;
  9. import org.apache.commons.httpclient.methods.PostMethod;
  10. import org.apache.commons.httpclient.methods.RequestEntity;
  11. import org.apache.commons.httpclient.methods.StringRequestEntity;
  12. import org.slf4j.Logger;
  13. import org.slf4j.LoggerFactory;
  14.  
  15. import java.io.BufferedReader;
  16. import java.io.IOException;
  17. import java.io.InputStream;
  18. import java.io.InputStreamReader;
  19.  
  20. /**
  21. * @ClassName: ApiUtil
  22. * @Description:
  23. * @Author LXYuuuuu
  24. * @Date 2020/6/30 9:47
  25. */
  26. public class XxlJobUtil {
  27.  
  28. public static Logger logger = LoggerFactory.getLogger(XxlJobUtil.class);
  29.  
  30. private static String cookie="";
  31.  
  32. /**
  33. * 新增/编辑任务
  34. * @param url
  35. * @param requestInfo
  36. * @return
  37. * @throws HttpException
  38. * @throws IOException
  39. */
  40. public static JSONObject addJob(String url, JSONObject requestInfo) throws HttpException, IOException {
  41. String path = "/jobinfo/add";
  42. String targetUrl = url + path;
  43. HttpClient httpClient = new HttpClient();
  44. PostMethod post = new PostMethod(targetUrl);
  45. RequestEntity requestEntity = new StringRequestEntity(requestInfo.toString(), "application/json", "utf-8");
  46. post.setRequestEntity(requestEntity);
  47. httpClient.executeMethod(post);
  48. JSONObject result = new JSONObject();
  49. result = getJsonObject(post, result);
  50. return result;
  51. }
  52.  
  53. public static JSONObject updateJob(String url, JSONObject requestInfo) throws HttpException, IOException {
  54. String path = "/jobinfo/update";
  55. String targetUrl = url + path;
  56. HttpClient httpClient = new HttpClient();
  57. PostMethod post = new PostMethod(targetUrl);
  58. RequestEntity requestEntity = new StringRequestEntity(requestInfo.toString(), "application/json", "utf-8");
  59. post.setRequestEntity(requestEntity);
  60. httpClient.executeMethod(post);
  61. JSONObject result = new JSONObject();
  62. result = getJsonObject(post, result);
  63. return result;
  64. }
  65.  
  66. /**
  67. * 删除任务
  68. * @param url
  69. * @param id
  70. * @return
  71. * @throws HttpException
  72. * @throws IOException
  73. */
  74. public static JSONObject deleteJob(String url,int id) throws HttpException, IOException {
  75. String path = "/jobinfo/delete?id="+id;
  76. return doGet(url,path);
  77. }
  78.  
  79. /**
  80. * 开始任务
  81. * @param url
  82. * @param id
  83. * @return
  84. * @throws HttpException
  85. * @throws IOException
  86. */
  87. public static JSONObject startJob(String url,int id) throws HttpException, IOException {
  88. String path = "/jobinfo/start?id="+id;
  89. return doGet(url,path);
  90. }
  91.  
  92. /**
  93. * 停止任务
  94. * @param url
  95. * @param id
  96. * @return
  97. * @throws HttpException
  98. * @throws IOException
  99. */
  100. public static JSONObject stopJob(String url,int id) throws HttpException, IOException {
  101. String path = "/jobinfo/stop?id="+id;
  102. return doGet(url,path);
  103. }
  104.  
  105. /**
  106. * 根据xxl-appname获取对应id
  107. * @param url
  108. * @param appnameParam
  109. * @return
  110. * @throws HttpException
  111. * @throws IOException
  112. */
  113. public static JSONObject getAppNameIdByAppname(String url,String appnameParam) throws HttpException, IOException {
  114. String path = "/jobgroup/getAppNameIdByAppname?appnameParam="+appnameParam;
  115. return doGet(url,path);
  116. }
  117.  
  118. public static JSONObject doGet(String url,String path) throws HttpException, IOException {
  119. String targetUrl = url + path;
  120. HttpClient httpClient = new HttpClient();
  121. HttpMethod get = new GetMethod(targetUrl);
  122. get.setRequestHeader("cookie", cookie);
  123. httpClient.executeMethod(get);
  124. JSONObject result = new JSONObject();
  125. result = getJsonObject(get, result);
  126. return result;
  127. }
  128.  
  129. private static JSONObject getJsonObject(HttpMethod get, JSONObject result) throws IOException {
  130. InputStream inputStream = get.getResponseBodyAsStream();
  131. BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
  132. StringBuffer stringBuffer = new StringBuffer();
  133. String str = "";
  134. while ((str = br.readLine()) != null) {
  135. stringBuffer.append(str);
  136. }
  137. if (get.getStatusCode() == 200) {
  138. /**
  139. * 使用此方式会出现
  140. * Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
  141. * 异常
  142. * String responseBodyAsString = get.getResponseBodyAsString();
  143. * result = JSONObject.parseObject(responseBodyAsString);*/
  144. result = JSONObject.parseObject(stringBuffer.toString());
  145. } else {
  146. try {
  147. // result = JSONObject.parseObject(get.getResponseBodyAsString());
  148. result = JSONObject.parseObject(stringBuffer.toString());
  149. } catch (Exception e) {
  150. result.put("error", stringBuffer.toString());
  151. }
  152. }
  153. return result;
  154. }
  155.  
  156. public static String login(String url, String userName, String password) throws HttpException, IOException {
  157. String path = "/jobinfo/login?userName="+userName+"&password="+password;
  158. String targetUrl = url + path;
  159. HttpClient httpClient = new HttpClient();
  160. HttpMethod get = new GetMethod(targetUrl);
  161. httpClient.executeMethod(get);
  162. if (get.getStatusCode() == 200) {
  163. Cookie[] cookies = httpClient.getState().getCookies();
  164. StringBuffer tmpcookies = new StringBuffer();
  165. for (Cookie c : cookies) {
  166. tmpcookies.append(c.toString() + ";");
  167. }
  168. cookie = tmpcookies.toString();
  169. } else {
  170. try {
  171. cookie = "";
  172. } catch (Exception e) {
  173. cookie="";
  174. }
  175. }
  176. return cookie;
  177. }
  178. }

TimeUtil 工具类

  1. public class TimeUtil {
  2. /***
  3. * convert Date to cron ,eg. "0 07 10 15 1 ? 2016"
  4. * @param date : 时间点
  5. * @return
  6. */
  7. public static String getCron(Date date) {
  8. String dateFormat = "ss mm HH dd MM ? yyyy";
  9. return formatDateByPattern(date, dateFormat);
  10. }
  11. }

Resp返回类

  1. /**
  2. * @program:
  3. * @description: 前端传递信息封装
  4. * @author: LXYuuuuu
  5. * @create: 2020-06-25 09:27
  6. **/
  7. public class Resp {
  8. /** 用于状态码 */
  9. public static final int SUCCESS = 200;
  10. public static final int ERROR = 404;
  11. public static final int TOKENERROR=1001;
  12. public static final int DATACOLLISION=1002;
  13.  
  14. /** 数据类型 */
  15. public static final String LIST = "LIST";
  16. public static final String SINGLE = "SINGLE";
  17. public static final String MAP = "MAP";
  18. public static final String PAGE = "PAGE";
  19. public static final String STRING = "STRING";
  20. public static final String JSONSTRING = "JSONSTRING";
  21.  
  22. /** 操作简单提示 */
  23. public static final String SUCCESS_INFO = "操作成功";
  24. public static final String ERROR_INFO = "操作失败";
  25. /** 状态码 */
  26. private int code;
  27. /** 返回提示信息 */
  28. private String message;
  29. /** 数据类型 */
  30. private String dataType;
  31. /** 返回对象 */
  32. private Object respBody;
  33.  
  34. private Resp() {}
  35.  
  36. /**
  37. * @Description: 返回实例化Resp
  38. * @return: Resp
  39. */
  40. public static Resp getInstantiation() {
  41. return new Resp();
  42. }
  43.  
  44. /**
  45. * @Description: 返回实例化Resp
  46. * @Param: @param code 状态码
  47. * @Param: @param message 返回提示信息
  48. * @Param: @param dataType 数据类型
  49. * @Param: @param respBody 返回对象
  50. * @return: Resp
  51. */
  52. public static Resp getInstantiation(int code,String message,String dataType,Object respBody) {
  53. Resp resp = getInstantiation();
  54. resp.setCode(code);
  55. resp.setMessage(message);
  56. resp.setDataType(dataType);
  57. resp.setRespBody(respBody);
  58. return resp;
  59. }
  60.  
  61. /**
  62. *
  63. * @Description: 返回状态为Success的实例化Resp
  64. * @Param: @param message 返回提示信息
  65. * @Param: @param dataType 数据类型
  66. * @Param: @param respBody 返回对象
  67. * @return: Resp
  68. */
  69. public static Resp getInstantiationSuccess(String message,String dataType,Object respBody) {
  70. return getInstantiation(SUCCESS, message, dataType, respBody);
  71. }
  72. public static Resp getInstantiationTokenError(String message,String dataType,Object respBody) {
  73. return getInstantiation(TOKENERROR, message, dataType, respBody);
  74. }
  75. public static Resp getInstantiationDATACOLLISIONError(String message,String dataType,Object respBody) {
  76. return getInstantiation(DATACOLLISION, message, dataType, respBody);
  77. }
  78. /**
  79. * @Description: 返回状态为Success的String类型实例化Resp
  80. * @Param: @param message 返回提示信息
  81. * @Param: @param respBody 返回对象
  82. * @return: Resp
  83. */
  84. public static Resp getInstantiationSuccessString(String message,Object respBody) {
  85. return getInstantiation(SUCCESS, message, STRING, respBody);
  86. }
  87. /**
  88. *
  89. * @author: zy
  90. * @Description: 返回状态为Success的List类型实例化Resp
  91. * @Param: @param message 返回提示信息
  92. * @Param: @param respBody 返回对象
  93. * @return: Resp
  94. */
  95. public static Resp getInstantiationSuccessList(String message,Object respBody) {
  96. return getInstantiation(SUCCESS, message, LIST, respBody);
  97. }
  98.  
  99. /**
  100. * @Description: 返回状态为Success的Map类型实例化Resp
  101. * @Param: @param message 返回提示信息
  102. * @Param: @param respBody 返回对象
  103. * @return: Resp
  104. */
  105. public static Resp getInstantiationSuccessMap(String message,Object respBody) {
  106. return getInstantiation(SUCCESS, message, MAP, respBody);
  107. }
  108. /**
  109. * @Description: 返回状态为Success的Page类型实例化Resp
  110. * @Param: @param message 返回提示信息
  111. * @Param: @param respBody 返回对象
  112. * @return: Resp
  113. */
  114. public static Resp getInstantiationSuccessPage(String message,Object respBody) {
  115. return getInstantiation(SUCCESS, message, PAGE, respBody);
  116. }
  117.  
  118. /**
  119. * @Description: 返回状态为Success的Page类型实例化Resp
  120. * @Param: @param message 返回提示信息
  121. * @Param: @param respBody 返回对象
  122. * @return: Resp
  123. */
  124. public static Resp getInstantiationSuccessJsonString(String message,Object respBody) {
  125. return getInstantiation(SUCCESS, message, JSONSTRING, respBody);
  126. }
  127.  
  128. /**
  129. * @Description: 返回状态为Error的实例化Resp
  130. * @Param: @param message 返回提示信息
  131. * @Param: @param dataType 数据类型
  132. * @Param: @param respBody 返回对象
  133. * @return: Resp
  134. */
  135. public static Resp getInstantiationError(String message,String dataType,Object respBody) {
  136. return getInstantiation(ERROR, message, dataType, respBody);
  137. }
  138. /**
  139. * @Description: 返回状态为Error的String类型实例化Resp
  140. * @Param: @param message 返回提示信息
  141. * @Param: @param respBody 返回对象
  142. * @return: Resp
  143. */
  144. public static Resp getInstantiationErrorString(String message,Object respBody) {
  145. return getInstantiation(ERROR, message, STRING, respBody);
  146. }
  147. /**
  148. * @Description: 返回状态为Error的List类型实例化Resp
  149. * @Param: @param message 返回提示信息
  150. * @Param: @param respBody 返回对象
  151. * @return: Resp
  152. */
  153. public static Resp getInstantiationErrorList(String message,Object respBody) {
  154. return getInstantiation(ERROR, message, LIST, respBody);
  155. }
  156. /**
  157. * @Description: 返回状态为Error的Map类型实例化Resp
  158. * @Param: @param message 返回提示信息
  159. * @Param: @param respBody 返回对象
  160. * @return: Resp
  161. */
  162. public static Resp getInstantiationErrorMap(String message,Object respBody) {
  163. return getInstantiation(ERROR, message, MAP, respBody);
  164. }
  165. /**
  166. * @Description: 返回状态为Error的Page类型实例化Resp
  167. * @Param: @param message 返回提示信息
  168. * @Param: @param respBody 返回对象
  169. * @return: Resp
  170. */
  171. public static Resp getInstantiationErrorPage(String message,Object respBody) {
  172. return getInstantiation(ERROR, message, PAGE, respBody);
  173. }
  174. /**
  175. * @Description: 返回状态为Error的JsonString类型实例化Resp
  176. * @Param: @param message 返回提示信息
  177. * @Param: @param respBody 返回对象
  178. * @return: Resp
  179. */
  180. public static Resp getInstantiationErrorJsonString(String message,Object respBody) {
  181. return getInstantiation(ERROR, message, JSONSTRING, respBody);
  182. }
  183.  
  184. public int getCode() {
  185. return code;
  186. }
  187. public void setCode(int code) {
  188. this.code = code;
  189. }
  190.  
  191. public String getMessage() {
  192. return message;
  193. }
  194. public void setMessage(String message) {
  195. this.message = message;
  196. }
  197.  
  198. public String getDataType() {
  199. return dataType;
  200. }
  201. public void setDataType(String dataType) {
  202. this.dataType = dataType;
  203. }
  204.  
  205. public Object getRespBody() {
  206. return respBody;
  207. }
  208. public void setRespBody(Object respBody) {
  209. this.respBody = respBody;
  210. }
  211.  
  212. /**
  213. * @Description: 判断是否成功
  214. * @return: boolean true:成功,false:错误
  215. */
  216. public boolean isSuccess() {
  217. return this.code==SUCCESS;
  218. }
  219.  
  220. }

到此,对外新增、编辑、删除、启动、挂起等接口就已经写好了。

任务调度中心xxl-job对外接口使用的更多相关文章

  1. 基于Spring AOP实现对外接口的耗时监控

    AOP是Spring的核心,Spring不但自身对多种框架的集成是基于AOP,并且以非常方便的形式暴露给普通使用者.以前用AOP不多,主要是因为它以横截面的方式插入到主流程中,担心导致主流程代码不够清 ...

  2. Spring boot下,集成任务调度中心(XXL-JOB)

    一.使用背景 目前项目中,采用的是微服务框架,由于在微服务中,存在需要定时的任务.但如果定时任务维护在每个微服务下,当微服务部署多个实例的情况下,会出现定事任务多次执行的情况.并且在解决问题的基础上, ...

  3. 利用Swagger2自动生成对外接口的文档

    一直以来做对外的接口文档都比较原始,基本上都是手写的文档传来传去,最近发现了一个新玩具,可以在接口上省去不少麻烦. swagger是一款方便展示的API文档框架.它可以将接口的类型最全面的展示给对方开 ...

  4. XXL-JOB原理--任务调度中心任务管理

    XXL-JOB原理--任务调度中心任务管理 https://blog.csdn.net/qq924862077/article/details/82713758

  5. python笔记44-HTTP对外接口sign签名

    前言 一般公司对外的接口都会用到sign签名,对不同的客户提供不同的apikey ,这样可以提高接口请求的安全性,避免被人抓包后乱请求. sign签名是一种很常见的方式 sign签名 签名参数sign ...

  6. EffectiveC#03--用委托表示回调,用事件定义对外接口

    1.回调的场景:我给了儿子一个任务且他可以报告状态来(重复的)打断我.而我在等待他完成任务的每一个部份时不用阻塞我自己的进程.他可以在有重要(或者事件)状态报告时,可以定时的打断我,或者向我询求帮助 ...

  7. 【JEECG技术文档】JEECG平台对外接口JWT应用文档V3.7.2

    一. 接口方式 接口调用采用http协议,rest请求方式: 二. 接口安全 接口安全采用Json web token (JWT)机制,基于token的鉴权机制. 1. 机制说明 基于token的鉴权 ...

  8. 快速开发框架(FDMS)新增1000个对外接口都不须要手写一行代码

    一个大型系统难免会跟其它系统有数据交换,这里就要提供数据接口给外部系统. 曾经在一家智能终端设备的公司上班.那段时间的主要工作就是写接口.接口须要与手机.手持设备.系统管理软件等进行数据交换.总结了一 ...

  9. python接口自动化:对外接口sign签名

    签名参数sign生成的方法: 在接口开发过程中,一般通过时间戳+sign作为密匙加密传输 实现代码如下: #python实现sign签名 import hashlib,time class sign: ...

随机推荐

  1. JavaWeb网上图书商城完整项目--day02-19.修改密码功能流程分析

    我们来看看修改密码的业务流程操作:

  2. Jmeter系列(30)- 详解 JDBC Request

    如果你想从头学习Jmeter,可以看看这个系列的文章哦 https://www.cnblogs.com/poloyy/category/1746599.html 前言 JDBC Request 主要是 ...

  3. Java 多线程基础(十二)生产者与消费者

    Java 多线程基础(十二)生产者与消费者 一.生产者与消费者模型 生产者与消费者问题是个非常典型的多线程问题,涉及到的对象包括“生产者”.“消费者”.“仓库”和“产品”.他们之间的关系如下: ①.生 ...

  4. Kubernetes 中 搭建 EFK 日志搜索中心

    简介 Elastic 官方已经发布了Elasticsearch Operator ,简化了 elasticsearch 以及 kibana的部署与升级,结合 fluentd-kubernetes-da ...

  5. Github中添加SSH key

    1-创建密钥,在终端输入下面的命令 ssh-keygen -t rsa -b -C "你的邮箱" //双引号不能去 要求输入密码,建议回车使用空密码方便以后的每次连接,此时会生成一 ...

  6. SQL注入基础原理

    Web安全: 三层架构(3-tier architecture) 通常意义上就是将整个业务应用划分为: 界面层(User Interface layer) 业务逻辑层(Business Logic L ...

  7. 洛谷 P3916 【图的遍历】

    这道题绿题有点高了吧... 我一开始的思路就是一个暴力的遍历,用递归加一个记忆化,对于一个点不断的往下搜索,然后确定最大的,返回,给上面的节点.就在这个过程中,我们是搜到最大的数然后返回给上层的数,那 ...

  8. Pycharm连接MySQL后出现不出现数据库或表,出现其他文件的问题

    在使用pycharm连接MySQL,配置完成,测试连接通过之后,还是不能显示数据库中的表,出现了许多像armscii8_bin.armscii8_general_ci和ascii_bin等的文件. 解 ...

  9. 什么是JSTL标签库?

    什么是JSTL? JSTL(JSP Standard Tag Library,JSP标准标签库)是一个不断完善的开放源代码的JSP标签库,是由apache的jakarta小组来维护的. 有什么作用? ...

  10. Tomcat的介绍

    Tomcat简介 Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选. 支持Se ...