删除jeecg-cloud-example例子模块,测试示例重构到jeecg-cloud-system-start中---

This commit is contained in:
zhangdaiscott
2021-02-21 14:36:44 +08:00
parent cb3d07b612
commit 0c3aab196b
22 changed files with 177 additions and 276 deletions

View File

@ -1,18 +1,15 @@
package org.jeecg;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.Context;
import org.apache.tomcat.util.scan.StandardJarScanner;
import org.jeecg.common.util.oConvertUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.net.InetAddress;
import java.net.UnknownHostException;
@ -24,6 +21,7 @@ import java.net.UnknownHostException;
@Slf4j
@SpringBootApplication
@EnableFeignClients(basePackages = {"org.jeecg"})
@EnableScheduling
public class JeecgSystemCloudApplication extends SpringBootServletInitializer {
@Override
@ -45,4 +43,5 @@ public class JeecgSystemCloudApplication extends SpringBootServletInitializer {
"----------------------------------------------------------");
}
}

View File

@ -0,0 +1,30 @@
package org.jeecg.modules.cloud.constant;
/**
* 微服务单元测试常量定义
*/
public interface CloudConstant {
/**
* 微服务名【对应模块jeecg-boot-module-demo】
*/
public final static String SERVER_NAME_JEECGDEMO = "jeecg-demo";
/**
* MQ测试队列名字
*/
public final static String MQ_JEECG_PLACE_ORDER = "jeecg_place_order";
public final static String MQ_JEECG_PLACE_ORDER_TIME = "jeecg_place_order_time";
/**
* MQ测试消息总线
*/
public final static String MQ_DEMO_BUS_EVENT = "demoBusEvent";
/**
* 分布式锁lock key
*/
public final static String REDISSON_DEMO_LOCK_KEY1 = "demoLockKey1";
public final static String REDISSON_DEMO_LOCK_KEY2 = "demoLockKey2";
}

View File

@ -0,0 +1,27 @@
package org.jeecg.modules.cloud.ebus;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.boot.starter.rabbitmq.event.EventObj;
import org.jeecg.boot.starter.rabbitmq.event.JeecgBusEventHandler;
import org.jeecg.common.base.BaseMap;
import org.jeecg.modules.cloud.constant.CloudConstant;
import org.springframework.stereotype.Component;
/**
* 消息处理器【发布订阅】
*/
@Slf4j
@Component(CloudConstant.MQ_DEMO_BUS_EVENT)
public class DemoBusEvent implements JeecgBusEventHandler {
@Override
public void onMessage(EventObj obj) {
if (ObjectUtil.isNotEmpty(obj)) {
BaseMap baseMap = obj.getBaseMap();
String orderId = baseMap.get("orderId");
log.info("业务处理----订单ID:" + orderId);
}
}
}

View File

@ -0,0 +1,61 @@
package org.jeecg.modules.cloud.feign.controller;
import cn.hutool.core.util.RandomUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.boot.starter.rabbitmq.client.RabbitMqClient;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.base.BaseMap;
import org.jeecg.modules.cloud.constant.CloudConstant;
import org.jeecg.modules.cloud.feign.feign.JeecgTestClient;
import org.jeecg.modules.cloud.feign.feign.JeecgTestClientDyn;
import org.jeecg.starter.cloud.feign.impl.JeecgFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping("/sys/test")
@Api(tags = "【微服务】单元测试")
public class JeecgTestFeignController {
@Autowired
private JeecgFeignService jeecgFeignService;
@Autowired
private JeecgTestClient jeecgTestClient;
@Autowired
private RabbitMqClient rabbitMqClient;
@GetMapping("getMessage")
@ApiOperation(value = "测试feign", notes = "测试feign")
public Result<String> getMessage() {
return jeecgTestClient.getMessage("jeecg-boot");
}
@GetMapping("getMessage2")
@ApiOperation(value = "测试动态feign", notes = "测试动态feign")
public Result<String> getMessage2() {
JeecgTestClientDyn myClientDyn = jeecgFeignService.newInstance(JeecgTestClientDyn.class, CloudConstant.SERVER_NAME_JEECGDEMO);
return myClientDyn.getMessage("动态fegin——jeecg-boot2");
}
@GetMapping(value = "/rabbitmq")
@ApiOperation(value = "测试rabbitmq", notes = "测试rabbitmq")
public Result<?> rabbitMqClientTest(HttpServletRequest req) {
//rabbitmq消息队列测试
BaseMap map = new BaseMap();
map.put("orderId", RandomUtil.randomNumbers(10));
rabbitMqClient.sendMessage(CloudConstant.MQ_JEECG_PLACE_ORDER, map);
rabbitMqClient.sendMessage(CloudConstant.MQ_JEECG_PLACE_ORDER_TIME, map,10);
//rabbitmq消息总线测试
BaseMap params = new BaseMap();
params.put("orderId", "123456");
rabbitMqClient.publishEvent(CloudConstant.MQ_DEMO_BUS_EVENT, params);
return Result.OK("MQ发送消息成功");
}
}

View File

@ -1,39 +0,0 @@
package org.jeecg.modules.cloud.feign.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.cloud.feign.feign.JeecgTestClient;
import org.jeecg.modules.cloud.feign.feign.JeecgTestClient2;
import org.jeecg.starter.cloud.feign.impl.JeecgFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/sys/test")
@Api(tags = "feign测试")
public class JeecgTestFeignTest {
@Autowired
private JeecgFeignService jeecgFeignService;
@Autowired
private JeecgTestClient jeecgTestClient;
@GetMapping("getMessage")
@ApiOperation(value = "测试feign", notes = "测试feign")
public Result<String> getMessage() {
return jeecgTestClient.getMessage("jeecg-boot");
}
@GetMapping("getMessage2")
@ApiOperation(value = "测试动态feign", notes = "测试动态feign")
public Result<String> getMessage2() {
JeecgTestClient2 jeecgTestClient = jeecgFeignService.newInstance(JeecgTestClient2.class, "jeecg-demo");
return jeecgTestClient.getMessage("jeecg-boot2");
}
}

View File

@ -1,6 +1,8 @@
package org.jeecg.modules.cloud.feign.feign;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.cloud.constant.CloudConstant;
import org.jeecg.modules.cloud.feign.feign.fallback.JeecgTestClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
@ -9,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestParam;
/**
* 常规feign接口定义
*/
@FeignClient(value = "jeecg-demo", fallbackFactory = DemoFallback.class)
@FeignClient(value = CloudConstant.SERVER_NAME_JEECGDEMO, fallbackFactory = JeecgTestClientFallback.class)
@Component
public interface JeecgTestClient {

View File

@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.RequestParam;
/**
* 动态feign接口定义
*/
public interface JeecgTestClient2 {
public interface JeecgTestClientDyn {
@GetMapping(value = "/test/getMessage")
Result<String> getMessage(@RequestParam("name") String name);

View File

@ -1,13 +1,14 @@
package org.jeecg.modules.cloud.feign.feign;
package org.jeecg.modules.cloud.feign.feign.fallback;
import feign.hystrix.FallbackFactory;
import org.jeecg.modules.cloud.feign.feign.JeecgTestClient;
import org.springframework.stereotype.Component;
/**
* @author qinfeng
*/
@Component
public class DemoFallback implements FallbackFactory<JeecgTestClient> {
public class JeecgTestClientFallback implements FallbackFactory<JeecgTestClient> {
@Override
public JeecgTestClient create(Throwable throwable) {

View File

@ -0,0 +1,65 @@
package org.jeecg.modules.cloud.lock;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.boot.starter.lock.annotation.DistributedLock;
import org.jeecg.boot.starter.lock.client.RedissonLockClient;
import org.jeecg.boot.starter.rabbitmq.client.RabbitMqClient;
import org.jeecg.common.base.BaseMap;
import org.jeecg.modules.cloud.constant.CloudConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* 分布式锁测试demo
*/
@Slf4j
@Component
public class DemoLockTest {
@Autowired
RedissonLockClient redissonLock;
@Autowired
RabbitMqClient rabbitMqClient;
/**
* 测试分布式锁【注解方式】
*/
@Scheduled(cron = "0/5 * * * * ?")
@DistributedLock(lockKey = CloudConstant.REDISSON_DEMO_LOCK_KEY1)
public void execute() throws InterruptedException {
log.info("执行execute任务开始休眠三秒");
Thread.sleep(3000);
System.out.println("=======================业务逻辑1=============================");
Map map = new BaseMap();
map.put("orderId", "BJ0001");
rabbitMqClient.sendMessage(CloudConstant.MQ_JEECG_PLACE_ORDER, map);
//延迟10秒发送
map.put("orderId", "NJ0002");
rabbitMqClient.sendMessage(CloudConstant.MQ_JEECG_PLACE_ORDER, map, 10000);
log.info("execute任务结束休眠三秒");
}
public DemoLockTest() {
}
/**
* 测试分布式锁【编码方式】
*/
//@Scheduled(cron = "0/5 * * * * ?")
public void execute2() throws InterruptedException {
if (redissonLock.tryLock(CloudConstant.REDISSON_DEMO_LOCK_KEY2, -1, 6000)) {
log.info("执行任务execute2开始休眠十秒");
Thread.sleep(10000);
System.out.println("=======================业务逻辑2=============================");
log.info("定时execute2结束休眠十秒");
redissonLock.unlock(CloudConstant.REDISSON_DEMO_LOCK_KEY2);
} else {
log.info("execute2获取锁失败");
}
}
}

View File

@ -1,16 +1,23 @@
package org.jeecg.modules.cloud.rabbitmq;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler;
import org.jeecg.boot.starter.rabbitmq.listenter.MqListener;
import org.jeecg.common.annotation.RabbitComponent;
import org.jeecg.common.base.BaseMap;
import org.jeecg.modules.cloud.constant.CloudConstant;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
@RabbitListener(queues = "jeecg_place_order")
/**
* RabbitMq接受者1
* @RabbitListener声明类上一个类只能监听一个队列
*/
@Slf4j
@RabbitListener(queues = CloudConstant.MQ_JEECG_PLACE_ORDER)
@RabbitComponent(value = "helloReceiver1")
public class HelloReceiver1 extends BaseRabbiMqHandler<BaseMap> {
@ -21,7 +28,7 @@ public class HelloReceiver1 extends BaseRabbiMqHandler<BaseMap> {
public void handler(BaseMap map, Channel channel) {
//业务处理
String orderId = map.get("orderId").toString();
System.out.println("Receiver1 : " + orderId);
log.info("MQ Receiver1orderId : " + orderId);
}
});
}

View File

@ -1,16 +1,23 @@
package org.jeecg.modules.cloud.rabbitmq;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler;
import org.jeecg.boot.starter.rabbitmq.listenter.MqListener;
import org.jeecg.common.annotation.RabbitComponent;
import org.jeecg.common.base.BaseMap;
import org.jeecg.modules.cloud.constant.CloudConstant;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
@RabbitListener(queues = "jeecg_place_order")
/**
* RabbitMq接受者2
* @RabbitListener声明类上一个类只能监听一个队列
*/
@Slf4j
@RabbitListener(queues = CloudConstant.MQ_JEECG_PLACE_ORDER)
@RabbitComponent(value = "helloReceiver2")
public class HelloReceiver2 extends BaseRabbiMqHandler<BaseMap> {
@ -21,7 +28,7 @@ public class HelloReceiver2 extends BaseRabbiMqHandler<BaseMap> {
public void handler(BaseMap map, Channel channel) {
//业务处理
String orderId = map.get("orderId").toString();
System.out.println("Receiver2 : " + orderId);
log.info("MQ Receiver2orderId : " + orderId);
}
});
}

View File

@ -0,0 +1,35 @@
package org.jeecg.modules.cloud.rabbitmq;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler;
import org.jeecg.boot.starter.rabbitmq.listenter.MqListener;
import org.jeecg.common.annotation.RabbitComponent;
import org.jeecg.common.base.BaseMap;
import org.jeecg.modules.cloud.constant.CloudConstant;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
/**
* RabbitMq接受者3
* @RabbitListener声明类方法上一个类可以多监听多个队列
*/
@Slf4j
@RabbitComponent(value = "helloReceiver3")
public class HelloReceiver3 extends BaseRabbiMqHandler<BaseMap> {
@RabbitListener(queues = CloudConstant.MQ_JEECG_PLACE_ORDER)
public void onMessage(BaseMap baseMap, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
super.onMessage(baseMap, deliveryTag, channel, new MqListener<BaseMap>() {
@Override
public void handler(BaseMap map, Channel channel) {
//业务处理
String orderId = map.get("orderId").toString();
log.info("MQ Receiver3orderId : " + orderId);
}
});
}
}

View File

@ -1,16 +1,19 @@
package org.jeecg.modules.cloud.rabbitmq;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.boot.starter.rabbitmq.core.BaseRabbiMqHandler;
import org.jeecg.boot.starter.rabbitmq.listenter.MqListener;
import org.jeecg.common.annotation.RabbitComponent;
import org.jeecg.common.base.BaseMap;
import org.jeecg.modules.cloud.constant.CloudConstant;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
@RabbitListener(queues = "jeecg_place_order_time")
@Slf4j
@RabbitListener(queues = CloudConstant.MQ_JEECG_PLACE_ORDER_TIME)
@RabbitComponent(value = "helloTimeReceiver")
public class HelloTimeReceiver extends BaseRabbiMqHandler<BaseMap> {
@ -21,7 +24,7 @@ public class HelloTimeReceiver extends BaseRabbiMqHandler<BaseMap> {
public void handler(BaseMap map, Channel channel) {
//业务处理
String orderId = map.get("orderId").toString();
System.out.println("Receiver1 : " + orderId);
log.info("Time Receiver1orderId : " + orderId);
}
});
}

View File

@ -1,57 +0,0 @@
package org.jeecg.modules.cloud.xxljob;;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import com.xxl.job.core.util.ShardingUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* xxl-job定时任务测试
*/
@Component
@Slf4j
public class Demo2JobHandler {
/**
* 简单任务
*
* @param params
* @return
*/
@XxlJob(value = "demoJob2")
public ReturnT<String> demoJobHandler(String params) {
log.info("我是定时任务,我执行了...............................");
return ReturnT.SUCCESS;
}
/**
* 2、分片广播任务
*/
@XxlJob("shardingJobHandler3")
public ReturnT<String> shardingJobHandler(String param) throws Exception {
// 分片参数
ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo();
XxlJobLogger.log("分片参数:当前分片序号 = {}, 总分片数 = {}", shardingVO.getIndex(), shardingVO.getTotal());
// 业务逻辑
for (int i = 0; i < shardingVO.getTotal(); i++) {
if (i == shardingVO.getIndex()) {
XxlJobLogger.log("第 {} 片, 命中分片开始处理", i);
} else {
XxlJobLogger.log("第 {} 片, 忽略", i);
}
}
return ReturnT.SUCCESS;
}
}

View File

@ -0,0 +1,235 @@
package org.jeecg.modules.cloud.xxljob;;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import com.xxl.job.core.util.ShardingUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
/**
* xxl-job定时任务测试
*/
@Component
@Slf4j
public class DemoJobHandler {
/**
* 简单任务
*
* @param params
* @return
*/
@XxlJob(value = "demoJob")
public ReturnT<String> demoJobHandler(String params) {
log.info("我是定时任务,我执行了...............................");
return ReturnT.SUCCESS;
}
/**
* 2、分片广播任务
*/
@XxlJob("shardingJobHandler")
public ReturnT<String> shardingJobHandler(String param) throws Exception {
// 分片参数
ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo();
XxlJobLogger.log("分片参数:当前分片序号 = {}, 总分片数 = {}", shardingVO.getIndex(), shardingVO.getTotal());
// 业务逻辑
for (int i = 0; i < shardingVO.getTotal(); i++) {
if (i == shardingVO.getIndex()) {
XxlJobLogger.log("第 {} 片, 命中分片开始处理", i);
} else {
XxlJobLogger.log("第 {} 片, 忽略", i);
}
}
return ReturnT.SUCCESS;
}
/**
* 3、命令行任务
*/
@XxlJob("commandJobHandler")
public ReturnT<String> commandJobHandler(String param) throws Exception {
String command = param;
int exitValue = -1;
BufferedReader bufferedReader = null;
try {
// command process
Process process = Runtime.getRuntime().exec(command);
BufferedInputStream bufferedInputStream = new BufferedInputStream(process.getInputStream());
bufferedReader = new BufferedReader(new InputStreamReader(bufferedInputStream));
// command log
String line;
while ((line = bufferedReader.readLine()) != null) {
XxlJobLogger.log(line);
}
// command exit
process.waitFor();
exitValue = process.exitValue();
} catch (Exception e) {
XxlJobLogger.log(e);
} finally {
if (bufferedReader != null) {
bufferedReader.close();
}
}
if (exitValue == 0) {
return IJobHandler.SUCCESS;
} else {
return new ReturnT<String>(IJobHandler.FAIL.getCode(), "command exit value(" + exitValue + ") is failed");
}
}
/**
* 4、跨平台Http任务
* 参数示例:
* "url: http://www.baidu.com\n" +
* "method: get\n" +
* "data: content\n";
*/
@XxlJob("httpJobHandler")
public ReturnT<String> httpJobHandler(String param) throws Exception {
// param parse
if (param == null || param.trim().length() == 0) {
XxlJobLogger.log("param[" + param + "] invalid.");
return ReturnT.FAIL;
}
String[] httpParams = param.split("\n");
String url = null;
String method = null;
String data = null;
for (String httpParam : httpParams) {
if (httpParam.startsWith("url:")) {
url = httpParam.substring(httpParam.indexOf("url:") + 4).trim();
}
if (httpParam.startsWith("method:")) {
method = httpParam.substring(httpParam.indexOf("method:") + 7).trim().toUpperCase();
}
if (httpParam.startsWith("data:")) {
data = httpParam.substring(httpParam.indexOf("data:") + 5).trim();
}
}
// param valid
if (url == null || url.trim().length() == 0) {
XxlJobLogger.log("url[" + url + "] invalid.");
return ReturnT.FAIL;
}
if (method == null || !Arrays.asList("GET", "POST").contains(method)) {
XxlJobLogger.log("method[" + method + "] invalid.");
return ReturnT.FAIL;
}
// request
HttpURLConnection connection = null;
BufferedReader bufferedReader = null;
try {
// connection
URL realUrl = new URL(url);
connection = (HttpURLConnection) realUrl.openConnection();
// connection setting
connection.setRequestMethod(method);
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setReadTimeout(5 * 1000);
connection.setConnectTimeout(3 * 1000);
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");
// do connection
connection.connect();
// data
if (data != null && data.trim().length() > 0) {
DataOutputStream dataOutputStream = new DataOutputStream(connection.getOutputStream());
dataOutputStream.write(data.getBytes("UTF-8"));
dataOutputStream.flush();
dataOutputStream.close();
}
// valid StatusCode
int statusCode = connection.getResponseCode();
if (statusCode != 200) {
throw new RuntimeException("Http Request StatusCode(" + statusCode + ") Invalid.");
}
// result
bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
StringBuilder result = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
result.append(line);
}
String responseMsg = result.toString();
XxlJobLogger.log(responseMsg);
return ReturnT.SUCCESS;
} catch (Exception e) {
XxlJobLogger.log(e);
return ReturnT.FAIL;
} finally {
try {
if (bufferedReader != null) {
bufferedReader.close();
}
if (connection != null) {
connection.disconnect();
}
} catch (Exception e2) {
XxlJobLogger.log(e2);
}
}
}
/**
* 5、生命周期任务示例任务初始化与销毁时支持自定义相关逻辑
*/
@XxlJob(value = "demoJobHandler2", init = "init", destroy = "destroy")
public ReturnT<String> demoJobHandler2(String param) throws Exception {
XxlJobLogger.log("XXL-JOB, Hello World.");
return ReturnT.SUCCESS;
}
public void init() {
log.info("init");
}
public void destroy() {
log.info("destory");
}
}