Browse Source

新增Nutz执行器Sample示例项目;

xuxueli 7 years ago
parent
commit
06c72af187
24 changed files with 149 additions and 167 deletions
  1. 32 29
      doc/XXL-JOB官方文档.md
  2. 2 1
      xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/config/JFinalCoreConfig.java
  3. 1 0
      xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/controller/IndexController.java
  4. 4 5
      xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/DemoJobHandler.java
  5. 1 1
      xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/resources/xxl-job-executor.properties
  6. 6 0
      xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/WEB-INF/web.xml
  7. 1 0
      xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/index.html
  8. 12 15
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/MainModule.java
  9. 27 18
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/config/NutzSetup.java
  10. 12 10
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/DemoJobHandler.java
  11. 5 4
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/ShardingJobHandler.java
  12. 6 8
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/module/IndexModule.java
  13. 0 38
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/ioc/dao.js
  14. 9 9
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/log4j.xml
  15. 2 2
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/xxl-job-executor.properties
  16. 0 12
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/index.jsp
  17. 13 3
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/web.xml
  18. 0 0
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/index
  19. 1 0
      xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/index.html
  20. 4 4
      xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
  21. 5 2
      xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/WEB-INF/web.xml
  22. 1 1
      xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/index.html
  23. 4 4
      xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
  24. 1 1
      xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties

+ 32 - 29
doc/XXL-JOB官方文档.md View File

386
 任务逻辑以JobHandler的形式存在于“执行器”所在项目中,开发流程如下:
386
 任务逻辑以JobHandler的形式存在于“执行器”所在项目中,开发流程如下:
387
 
387
 
388
 #### 步骤一:执行器项目中,开发JobHandler:
388
 #### 步骤一:执行器项目中,开发JobHandler:
389
-    - 1、 新建一个继承com.xxl.job.core.handler.IJobHandler的Java类;
390
-    - 2、 该类被Spring容器扫描为Bean实例,如加“@Component”注解;
391
-    - 3、 添加 “@JobHandler(value="自定义jobhandler名称")”注解,注解的value值为自定义的JobHandler名称,该名称对应的是调度中心新建任务的JobHandler属性的值。
389
+
390
+     - 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”;
391
+     - 2、注册到Spring容器:添加“@Component”注解,被Spring容器扫描为Bean实例;
392
+     - 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。
393
+     - 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
392
     (可参考Sample示例执行器中的DemoJobHandler,见下图)
394
     (可参考Sample示例执行器中的DemoJobHandler,见下图)
393
 
395
 
394
 ![输入图片说明](https://static.oschina.net/uploads/img/201607/23232347_oLlM.png "在这里输入图片标题")
396
 ![输入图片说明](https://static.oschina.net/uploads/img/201607/23232347_oLlM.png "在这里输入图片标题")
1073
 - 10、任务日志文件路径时间戳格式化时SimpleDateFormat并发问题解决;
1075
 - 10、任务日志文件路径时间戳格式化时SimpleDateFormat并发问题解决;
1074
 
1076
 
1075
 ### 6.20 版本 V1.9.0 特性[迭代中]
1077
 ### 6.20 版本 V1.9.0 特性[迭代中]
1076
-- 1、新增任务运行模式 "GLUE模式(NodeJS) ",支持NodeJS脚本任务;
1077
-- 2、脚本任务Shell、Python和Nodejs等支持获取分片参数;
1078
-- 3、失败重试,完整支持:调度中心调度失败且启用"失败重试"策略时,将会自动重试一次;执行器执行失败且回调失败重试状态(新增失败重试状态返回值)时,也将会自动重试一次;
1079
-- 4、失败告警策略扩展:默认提供邮件失败告警,可扩展短信等,扩展代码位置为 "JobFailMonitorHelper.failAlarm";
1080
-- 5、执行器端口支持自动生成(小于等于0时),避免端口定义冲突;
1081
-- 6、调度报表优化,支持时间区间筛选;
1082
-- 7、Log组件支持输出异常栈信息,底层实现优化;
1083
-- 8、告警邮件样式优化,调整为表格形式,邮件组件调整为commons-email简化邮件操作;
1084
-- 9、项目依赖升级,如spring、jackson等;
1085
-- 10、任务日志,记录发起调度的机器信息;
1086
-- 11、交互优化,如登陆注销;
1087
-- 12、任务Cron长度扩展支持至128位,支持负责类型Cron设置;
1088
-- 13、执行器地址录入交互优化,地址长度扩展支持至512位,支持大规模执行器集群配置;
1089
-- 14、任务参数“IJobHandler.execute”入参改为“String params”,增强入参通用性。
1090
-- 15、JobHandler提供init/destroy方法,支持在JobHandler初始化和销毁时进行附加操作;
1091
-- 16、任务注解调整为 “@JobHandler”,与任务抽象接口统一;
1092
-- 17、修复任务监控线程被耗时任务阻塞的问题;
1093
-- 18、修复任务监控线程无法监控任务触发和执行状态均未0的问题;
1094
-- 19、执行器动态代理对象,拦截非业务方法的执行;
1095
-- 20、修复JobThread捕获Error错误不更新JobLog的问题;
1096
-- 21、修复任务列表界面左侧菜单合并时样式错乱问题;
1097
-- 22、调度中心项目日志配置改为xml文件格式;
1098
-- 23、Log地址格式兼容,支持非"/"结尾路径配置;
1099
-- 24、底层系统日志级别规范调整,清理遗留代码;
1100
-- 25、建表SQL优化,支持同步创建制定编码的库和表;
1101
-- 26、Nutz执行器Sample示例项目;
1078
+- 1、新增Nutz执行器Sample示例项目;
1079
+- 2、新增任务运行模式 "GLUE模式(NodeJS) ",支持NodeJS脚本任务;
1080
+- 3、脚本任务Shell、Python和Nodejs等支持获取分片参数;
1081
+- 4、失败重试,完整支持:调度中心调度失败且启用"失败重试"策略时,将会自动重试一次;执行器执行失败且回调失败重试状态(新增失败重试状态返回值)时,也将会自动重试一次;
1082
+- 5、失败告警策略扩展:默认提供邮件失败告警,可扩展短信等,扩展代码位置为 "JobFailMonitorHelper.failAlarm";
1083
+- 6、执行器端口支持自动生成(小于等于0时),避免端口定义冲突;
1084
+- 7、调度报表优化,支持时间区间筛选;
1085
+- 8、Log组件支持输出异常栈信息,底层实现优化;
1086
+- 9、告警邮件样式优化,调整为表格形式,邮件组件调整为commons-email简化邮件操作;
1087
+- 10、项目依赖升级,如spring、jackson等;
1088
+- 11、任务日志,记录发起调度的机器信息;
1089
+- 12、交互优化,如登陆注销;
1090
+- 13、任务Cron长度扩展支持至128位,支持负责类型Cron设置;
1091
+- 14、执行器地址录入交互优化,地址长度扩展支持至512位,支持大规模执行器集群配置;
1092
+- 15、任务参数“IJobHandler.execute”入参改为“String params”,增强入参通用性。
1093
+- 16、JobHandler提供init/destroy方法,支持在JobHandler初始化和销毁时进行附加操作;
1094
+- 17、任务注解调整为 “@JobHandler”,与任务抽象接口统一;
1095
+- 18、修复任务监控线程被耗时任务阻塞的问题;
1096
+- 19、修复任务监控线程无法监控任务触发和执行状态均未0的问题;
1097
+- 20、执行器动态代理对象,拦截非业务方法的执行;
1098
+- 21、修复JobThread捕获Error错误不更新JobLog的问题;
1099
+- 22、修复任务列表界面左侧菜单合并时样式错乱问题;
1100
+- 23、调度中心项目日志配置改为xml文件格式;
1101
+- 24、Log地址格式兼容,支持非"/"结尾路径配置;
1102
+- 25、底层系统日志级别规范调整,清理遗留代码;
1103
+- 26、建表SQL优化,支持同步创建制定编码的库和表;
1104
+
1102
 
1105
 
1103
 
1106
 
1104
 ### TODO LIST
1107
 ### TODO LIST

+ 2 - 1
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/config/JFinalCoreConfig.java View File

17
 	private Logger logger = LoggerFactory.getLogger(JFinalCoreConfig.class);
17
 	private Logger logger = LoggerFactory.getLogger(JFinalCoreConfig.class);
18
 
18
 
19
 	// ---------------------- xxl-job executor ----------------------
19
 	// ---------------------- xxl-job executor ----------------------
20
-	XxlJobExecutor xxlJobExecutor = null;
20
+	private XxlJobExecutor xxlJobExecutor = null;
21
 	private void initXxlJobExecutor() {
21
 	private void initXxlJobExecutor() {
22
+
22
 		// registry jobhandler
23
 		// registry jobhandler
23
 		XxlJobExecutor.registJobHandler("demoJobHandler", new DemoJobHandler());
24
 		XxlJobExecutor.registJobHandler("demoJobHandler", new DemoJobHandler());
24
 		XxlJobExecutor.registJobHandler("shardingJobHandler", new ShardingJobHandler());
25
 		XxlJobExecutor.registJobHandler("shardingJobHandler", new ShardingJobHandler());

+ 1 - 0
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/controller/IndexController.java View File

7
 	public void index(){
7
 	public void index(){
8
 		renderText("xxl job executor running.");
8
 		renderText("xxl job executor running.");
9
 	}
9
 	}
10
+
10
 }
11
 }

+ 4 - 5
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/DemoJobHandler.java View File

6
 
6
 
7
 import java.util.concurrent.TimeUnit;
7
 import java.util.concurrent.TimeUnit;
8
 
8
 
9
-
10
 /**
9
 /**
11
- * 任务Handler的一个Demo(Bean模式)
10
+ * 任务Handler示例(Bean模式)
12
  *
11
  *
13
  * 开发步骤:
12
  * 开发步骤:
14
- * 1、继承 “IJobHandler” 
15
- * 2、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
16
- * 3、在 "JFinalCoreConfig" 中注册,执行Jobhandler名称
13
+ * 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”
14
+ * 2、注册到执行器工厂:在 "JFinalCoreConfig.initXxlJobExecutor" 中手动注册,注解key值对应的是调度中心新建任务的JobHandler属性的值。
15
+ * 3、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志
17
  *
16
  *
18
  * @author xuxueli 2015-12-19 19:43:36
17
  * @author xuxueli 2015-12-19 19:43:36
19
  */
18
  */

+ 1 - 1
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/resources/xxl-job-executor.properties View File

4
 ### xxl-job executor address
4
 ### xxl-job executor address
5
 xxl.job.executor.appname=xxl-job-executor-sample
5
 xxl.job.executor.appname=xxl-job-executor-sample
6
 xxl.job.executor.ip=
6
 xxl.job.executor.ip=
7
-xxl.job.executor.port=9997
7
+xxl.job.executor.port=9996
8
 
8
 
9
 ### xxl-job log path
9
 ### xxl-job log path
10
 xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
10
 xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler

+ 6 - 0
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/WEB-INF/web.xml View File

3
 	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
3
 	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4
 	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4
 	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
5
 	id="WebApp_ID" version="2.5">
5
 	id="WebApp_ID" version="2.5">
6
+
6
 	<display-name>xxl-job-executor-sample-jfinal</display-name>
7
 	<display-name>xxl-job-executor-sample-jfinal</display-name>
7
 	<context-param>
8
 	<context-param>
8
 		<param-name>webAppRootKey</param-name>
9
 		<param-name>webAppRootKey</param-name>
23
 		<url-pattern>/*</url-pattern>
24
 		<url-pattern>/*</url-pattern>
24
 	</filter-mapping>
25
 	</filter-mapping>
25
 
26
 
27
+
28
+	<welcome-file-list>
29
+		<welcome-file>index.html</welcome-file>
30
+	</welcome-file-list>
31
+
26
 </web-app>
32
 </web-app>

+ 1 - 0
xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/index.html View File

1
+i am alive.

+ 12 - 15
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/MainModule.java View File

1
 package com.xuxueli.executor.sample.nutz;
1
 package com.xuxueli.executor.sample.nutz;
2
 
2
 
3
-import org.nutz.mvc.annotation.Encoding;
4
-import org.nutz.mvc.annotation.Fail;
5
-import org.nutz.mvc.annotation.IocBy;
6
-import org.nutz.mvc.annotation.Localization;
7
-import org.nutz.mvc.annotation.Modules;
8
-import org.nutz.mvc.annotation.Ok;
9
-import org.nutz.mvc.annotation.SetupBy;
3
+import com.xuxueli.executor.sample.nutz.config.NutzSetup;
4
+import org.nutz.mvc.annotation.*;
10
 import org.nutz.mvc.ioc.provider.ComboIocProvider;
5
 import org.nutz.mvc.ioc.provider.ComboIocProvider;
6
+
11
 /**
7
 /**
12
- * 
13
- * @author 邓华锋
8
+ * nutz module
14
  *
9
  *
10
+ * @author xuxueli 2017-12-25 17:58:43
15
  */
11
  */
16
-@IocBy(type=ComboIocProvider.class,args={"*org.nutz.ioc.loader.json.JsonLoader","ioc/",
17
-	  "*org.nutz.ioc.loader.annotation.AnnotationIocLoader","com.xuxueli"})
18
-@Encoding(input="utf-8",output="utf-8")
19
-@Modules(scanPackage=true)
12
+@IocBy(type = ComboIocProvider.class,
13
+        args = {"*org.nutz.ioc.loader.annotation.AnnotationIocLoader",
14
+                "com.xuxueli.executor.sample.nutz"})
15
+@Encoding(input = "utf-8", output = "utf-8")
16
+@Modules(scanPackage = true)
20
 @Localization("msg")
17
 @Localization("msg")
21
 @Ok("json")
18
 @Ok("json")
22
 @Fail("json")
19
 @Fail("json")
23
-@SetupBy(MainSetup.class)
20
+@SetupBy(NutzSetup.class)
24
 public class MainModule {
21
 public class MainModule {
25
-	
22
+
26
 }
23
 }

xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/MainSetup.java → xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/config/NutzSetup.java View File

1
-package com.xuxueli.executor.sample.nutz;
1
+package com.xuxueli.executor.sample.nutz.config;
2
 
2
 
3
-import org.nutz.ioc.IocException;
3
+import com.xxl.job.core.executor.XxlJobExecutor;
4
+import com.xxl.job.core.handler.IJobHandler;
5
+import com.xxl.job.core.handler.annotation.JobHandler;
4
 import org.nutz.ioc.impl.PropertiesProxy;
6
 import org.nutz.ioc.impl.PropertiesProxy;
5
-import org.nutz.log.Log;
6
-import org.nutz.log.Logs;
7
 import org.nutz.mvc.NutConfig;
7
 import org.nutz.mvc.NutConfig;
8
 import org.nutz.mvc.Setup;
8
 import org.nutz.mvc.Setup;
9
-
10
-import com.xxl.job.core.executor.XxlJobExecutor;
11
-import com.xxl.job.core.handler.IJobHandler;
9
+import org.slf4j.Logger;
10
+import org.slf4j.LoggerFactory;
12
 
11
 
13
 /**
12
 /**
14
- * 
15
- * @author 邓华锋
13
+ * nutz setup
16
  *
14
  *
15
+ * @author xuxueli 2017-12-25 17:58:43
17
  */
16
  */
18
-public class MainSetup implements Setup {
19
-	public static final Log log = Logs.get();
20
-	XxlJobExecutor xxlJobExecutor = null;
17
+public class NutzSetup implements Setup {
18
+	private Logger logger = LoggerFactory.getLogger(NutzSetup.class);
19
+	//public static final Log logger = Logs.get();
20
+
21
+	private XxlJobExecutor xxlJobExecutor = null;
21
 
22
 
22
 	@Override
23
 	@Override
23
 	public void init(NutConfig cfg) {
24
 	public void init(NutConfig cfg) {
24
-		// 通用注册IJobHandler
25
-		String[] names = cfg.getIoc().getNamesByType(IJobHandler.class);
26
-		for (String name : names) {
27
-			XxlJobExecutor.registJobHandler(name, cfg.getIoc().get(IJobHandler.class, name));
25
+
26
+		// regist JobHandler
27
+		String[] beanNames = cfg.getIoc().getNamesByType(IJobHandler.class);
28
+		if (beanNames==null || beanNames.length==0) {
29
+			return;
30
+		}
31
+		for (String beanName : beanNames) {
32
+			IJobHandler jobHandler = cfg.getIoc().get(IJobHandler.class, beanName);
33
+			String name = jobHandler.getClass().getAnnotation(JobHandler.class).value();
34
+			XxlJobExecutor.registJobHandler(name, jobHandler);
28
 		}
35
 		}
36
+
29
 		// load executor prop
37
 		// load executor prop
30
-		PropertiesProxy xxlJobProp = cfg.getIoc().get(PropertiesProxy.class, "conf");
38
+		PropertiesProxy xxlJobProp = new PropertiesProxy("xxl-job-executor.properties");
31
 
39
 
32
 		// init executor
40
 		// init executor
33
 		xxlJobExecutor = new XxlJobExecutor();
41
 		xxlJobExecutor = new XxlJobExecutor();
42
 		try {
50
 		try {
43
 			xxlJobExecutor.start();
51
 			xxlJobExecutor.start();
44
 		} catch (Exception e) {
52
 		} catch (Exception e) {
45
-			log.error(e.getMessage(), e);
53
+			logger.error(e.getMessage(), e);
46
 		}
54
 		}
47
 	}
55
 	}
48
 
56
 
52
 			xxlJobExecutor.destroy();
60
 			xxlJobExecutor.destroy();
53
 		}
61
 		}
54
 	}
62
 	}
63
+
55
 }
64
 }

+ 12 - 10
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/DemoJobHandler.java View File

1
 package com.xuxueli.executor.sample.nutz.jobhandler;
1
 package com.xuxueli.executor.sample.nutz.jobhandler;
2
 
2
 
3
-import java.util.concurrent.TimeUnit;
4
-
5
-import org.nutz.ioc.loader.annotation.IocBean;
6
-
7
 import com.xxl.job.core.biz.model.ReturnT;
3
 import com.xxl.job.core.biz.model.ReturnT;
8
 import com.xxl.job.core.handler.IJobHandler;
4
 import com.xxl.job.core.handler.IJobHandler;
5
+import com.xxl.job.core.handler.annotation.JobHandler;
9
 import com.xxl.job.core.log.XxlJobLogger;
6
 import com.xxl.job.core.log.XxlJobLogger;
7
+import org.nutz.ioc.loader.annotation.IocBean;
10
 
8
 
9
+import java.util.concurrent.TimeUnit;
11
 
10
 
12
 /**
11
 /**
13
- * 任务Handler的一个Demo(Bean模式)
12
+ * 任务Handler示例(Bean模式)
14
  *
13
  *
15
  * 开发步骤:
14
  * 开发步骤:
16
- * 1、继承 “IJobHandler” ;
17
- * 2、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
18
- * 3、在 "JFinalCoreConfig" 中注册,执行Jobhandler名称;
15
+ * 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”;
16
+ * 2、注册到Nutz容器:添加“@IocBean”注解,被Nutz容器扫描为Bean实例;
17
+ * 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。
18
+ * 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
19
  *
19
  *
20
  * @author xuxueli 2015-12-19 19:43:36
20
  * @author xuxueli 2015-12-19 19:43:36
21
  */
21
  */
22
+@JobHandler(value="demoJobHandler")
22
 @IocBean
23
 @IocBean
23
 public class DemoJobHandler extends IJobHandler {
24
 public class DemoJobHandler extends IJobHandler {
24
 
25
 
25
 	@Override
26
 	@Override
26
-	public ReturnT<String> execute(String... params) throws Exception {
27
+	public ReturnT<String> execute(String param) throws Exception {
27
 		XxlJobLogger.log("XXL-JOB, Hello World.");
28
 		XxlJobLogger.log("XXL-JOB, Hello World.");
28
 
29
 
29
 		for (int i = 0; i < 5; i++) {
30
 		for (int i = 0; i < 5; i++) {
30
 			XxlJobLogger.log("beat at:" + i);
31
 			XxlJobLogger.log("beat at:" + i);
31
 			TimeUnit.SECONDS.sleep(2);
32
 			TimeUnit.SECONDS.sleep(2);
32
 		}
33
 		}
33
-		return ReturnT.SUCCESS;
34
+		return SUCCESS;
34
 	}
35
 	}
35
 
36
 
36
 }
37
 }
38
+

+ 5 - 4
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/ShardingJobHandler.java View File

1
 package com.xuxueli.executor.sample.nutz.jobhandler;
1
 package com.xuxueli.executor.sample.nutz.jobhandler;
2
 
2
 
3
+import com.xxl.job.core.handler.annotation.JobHandler;
3
 import org.nutz.ioc.loader.annotation.IocBean;
4
 import org.nutz.ioc.loader.annotation.IocBean;
4
 
5
 
5
 import com.xxl.job.core.biz.model.ReturnT;
6
 import com.xxl.job.core.biz.model.ReturnT;
7
 import com.xxl.job.core.log.XxlJobLogger;
8
 import com.xxl.job.core.log.XxlJobLogger;
8
 import com.xxl.job.core.util.ShardingUtil;
9
 import com.xxl.job.core.util.ShardingUtil;
9
 
10
 
10
-
11
 /**
11
 /**
12
  * 分片广播任务
12
  * 分片广播任务
13
  *
13
  *
14
  * @author xuxueli 2017-07-25 20:56:50
14
  * @author xuxueli 2017-07-25 20:56:50
15
  */
15
  */
16
+@JobHandler(value="shardingJobHandler")
16
 @IocBean
17
 @IocBean
17
 public class ShardingJobHandler extends IJobHandler {
18
 public class ShardingJobHandler extends IJobHandler {
18
 
19
 
19
 	@Override
20
 	@Override
20
-	public ReturnT<String> execute(String... params) throws Exception {
21
+	public ReturnT<String> execute(String param) throws Exception {
21
 
22
 
22
 		// 分片参数
23
 		// 分片参数
23
 		ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo();
24
 		ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo();
32
 			}
33
 			}
33
 		}
34
 		}
34
 
35
 
35
-		return ReturnT.SUCCESS;
36
+		return SUCCESS;
36
 	}
37
 	}
37
-	
38
+
38
 }
39
 }

+ 6 - 8
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/module/IndexModule.java View File

3
 import org.nutz.ioc.loader.annotation.IocBean;
3
 import org.nutz.ioc.loader.annotation.IocBean;
4
 import org.nutz.mvc.annotation.At;
4
 import org.nutz.mvc.annotation.At;
5
 import org.nutz.mvc.annotation.Ok;
5
 import org.nutz.mvc.annotation.Ok;
6
-/**
7
- * 
8
- * @author 邓华锋
9
- *
10
- */
6
+
11
 @IocBean
7
 @IocBean
12
 public class IndexModule {
8
 public class IndexModule {
13
 	
9
 	
14
-	@At
15
-	@Ok("jsp:index")
16
-	public void index() {
10
+	@At("/")
11
+	@Ok("json")
12
+	public String index() {
13
+		return "xxl job executor running.";
17
 	}
14
 	}
15
+
18
 }
16
 }

+ 0 - 38
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/ioc/dao.js View File

1
-var ioc = {
2
-	conf : {
3
-		type : "org.nutz.ioc.impl.PropertiesProxy",
4
-		fields : {
5
-			paths : [ "custom/" ]
6
-		}
7
-	},
8
-	/**
9
-	 * 配置单例job执行
10
-	 */
11
-	/*xxlJobExecutor : {
12
-		type : "com.xxl.job.core.executor.XxlJobExecutor",
13
-		events : {
14
-			create : "start",
15
-			depose : "destroy"
16
-		},
17
-		fields : {
18
-			ip : {
19
-				java : "$conf.get('xxl.job.executor.ip')"
20
-			},
21
-			port : {
22
-				java : "$conf.get('xxl.job.executor.port')"
23
-			},
24
-			appName : {
25
-				java : "$conf.get('xxl.job.executor.appname')"
26
-			},
27
-			adminAddresses : {
28
-				java : "$conf.get('xxl.job.admin.addresses')"
29
-			},
30
-			logPath : {
31
-				java : "$conf.get('xxl.job.executor.logpath')"
32
-			},
33
-			accessToken : {
34
-				java : "$conf.get('xxl.job.accessToken')"
35
-			}
36
-		}
37
-	}*/
38
-};

+ 9 - 9
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/log4j.xml View File

2
 <!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
2
 <!DOCTYPE log4j:configuration PUBLIC "-//log4j/log4j Configuration//EN" "log4j.dtd">
3
 <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" threshold="null" debug="null">
3
 <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" threshold="null" debug="null">
4
 
4
 
5
-	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
6
-		<param name="Target" value="System.out" />
7
-		<layout class="org.apache.log4j.PatternLayout">
8
-            <param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} spider-executor [%c]-[%t]-[%M]-[%L]-[%p] %m%n"/>
9
-		</layout>
10
-	</appender>
11
-	
5
+    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
6
+        <param name="Target" value="System.out" />
7
+        <layout class="org.apache.log4j.PatternLayout">
8
+            <param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-sample-nutz [%c]-[%t]-[%M]-[%L]-[%p] %m%n"/>
9
+        </layout>
10
+    </appender>
11
+
12
     <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
12
     <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
13
-        <param name="file" value="/data/applogs/xxl-job/spider-executor.log"/>
13
+        <param name="file" value="/data/applogs/xxl-job/xxl-job-executor-sample-nutz.log"/>
14
         <param name="append" value="true"/>
14
         <param name="append" value="true"/>
15
         <param name="encoding" value="UTF-8"/>
15
         <param name="encoding" value="UTF-8"/>
16
         <layout class="org.apache.log4j.PatternLayout">
16
         <layout class="org.apache.log4j.PatternLayout">
17
-            <param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} spider-executor [%c]-[%t]-[%M]-[%L]-[%p] %m%n"/>
17
+            <param name="ConversionPattern" value="%-d{yyyy-MM-dd HH:mm:ss} xxl-job-executor-sample-nutz [%c]-[%t]-[%M]-[%L]-[%p] %m%n"/>
18
         </layout>
18
         </layout>
19
     </appender>
19
     </appender>
20
 
20
 

xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/custom/xxl-job-executor.properties → xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/xxl-job-executor.properties View File

4
 ### xxl-job executor address
4
 ### xxl-job executor address
5
 xxl.job.executor.appname=xxl-job-executor-sample
5
 xxl.job.executor.appname=xxl-job-executor-sample
6
 xxl.job.executor.ip=
6
 xxl.job.executor.ip=
7
-xxl.job.executor.port=1024
7
+xxl.job.executor.port=9997
8
 
8
 
9
 ### xxl-job log path
9
 ### xxl-job log path
10
-xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler/
10
+xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
11
 
11
 
12
 ### xxl-job, access token
12
 ### xxl-job, access token
13
 xxl.job.accessToken=
13
 xxl.job.accessToken=

+ 0 - 12
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/index.jsp View File

1
-<%@ page language="java" contentType="text/html; charset=UTF-8"
2
-    pageEncoding="UTF-8"%>
3
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4
-<html>
5
-<head>
6
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7
-<title>nutz 执行器启动成功</title>
8
-</head>
9
-<body>
10
-nutz 执行器启动成功!
11
-</body>
12
-</html>

+ 13 - 3
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/web.xml View File

3
 	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
3
 	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4
 	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4
 	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
5
 	id="WebApp_ID" version="2.5">
5
 	id="WebApp_ID" version="2.5">
6
+
6
 	<display-name>xxl-job-executor-sample-nutz</display-name>
7
 	<display-name>xxl-job-executor-sample-nutz</display-name>
8
+	<context-param>
9
+		<param-name>webAppRootKey</param-name>
10
+		<param-value>xxl-job-executor-sample-nutz</param-value>
11
+	</context-param>
12
+
13
+	<!-- nutz -->
7
 	<filter>
14
 	<filter>
8
-		<filter-name>xxl-job-executor-sample-nutz</filter-name>
15
+		<filter-name>nutz</filter-name>
9
 		<filter-class>org.nutz.mvc.NutFilter</filter-class>
16
 		<filter-class>org.nutz.mvc.NutFilter</filter-class>
10
 		<init-param>
17
 		<init-param>
11
 			<param-name>modules</param-name>
18
 			<param-name>modules</param-name>
13
 		</init-param>
20
 		</init-param>
14
 	</filter>
21
 	</filter>
15
 	<filter-mapping>
22
 	<filter-mapping>
16
-		<filter-name>xxl-job-executor-sample-nutz</filter-name>
23
+		<filter-name>nutz</filter-name>
17
 		<url-pattern>/*</url-pattern>
24
 		<url-pattern>/*</url-pattern>
18
 	</filter-mapping>
25
 	</filter-mapping>
26
+
27
+
19
 	<welcome-file-list>
28
 	<welcome-file-list>
20
-		<welcome-file>index</welcome-file>
29
+		<welcome-file>index.html</welcome-file>
21
 	</welcome-file-list>
30
 	</welcome-file-list>
31
+
22
 </web-app>
32
 </web-app>

+ 0 - 0
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/index View File


+ 1 - 0
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/index.html View File

1
+i am alive.

+ 4 - 4
xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java View File

10
 
10
 
11
 
11
 
12
 /**
12
 /**
13
- * 任务Handler的一个Demo(Bean模式)
13
+ * 任务Handler示例(Bean模式)
14
  * 
14
  * 
15
  * 开发步骤:
15
  * 开发步骤:
16
- * 1、新建一个继承com.xxl.job.core.handler.IJobHandler的Java类
17
- * 2、该类被Spring容器扫描为Bean实例,如加“@Component”注解
18
- * 3、添加 “@JobHandler(value="自定义jobhandler名称")”注解,注解value值为自定义的JobHandler名称,该名称对应的是调度中心新建任务的JobHandler属性的值。
16
+ * 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”
17
+ * 2、注册到Spring容器:添加“@Component”注解,被Spring容器扫描为Bean实例
18
+ * 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。
19
  * 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
19
  * 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
20
  * 
20
  * 
21
  * @author xuxueli 2015-12-19 19:43:36
21
  * @author xuxueli 2015-12-19 19:43:36

+ 5 - 2
xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/WEB-INF/web.xml View File

3
 	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee"
3
 	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee"
4
 	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4
 	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
5
 	id="WebApp_ID" version="2.5">
5
 	id="WebApp_ID" version="2.5">
6
+
6
 	<display-name>xxl-job-executor-sample-spring</display-name>
7
 	<display-name>xxl-job-executor-sample-spring</display-name>
7
 	<context-param>
8
 	<context-param>
8
 	    <param-name>webAppRootKey</param-name>
9
 	    <param-name>webAppRootKey</param-name>
9
 	    <param-value>xxl-job-executor-sample-spring</param-value>
10
 	    <param-value>xxl-job-executor-sample-spring</param-value>
10
 	</context-param>
11
 	</context-param>
11
-	
12
+
13
+	<!-- spring -->
12
 	<context-param>
14
 	<context-param>
13
 		<param-name>contextConfigLocation</param-name>
15
 		<param-name>contextConfigLocation</param-name>
14
 		<param-value>classpath*:applicationcontext-*.xml</param-value>
16
 		<param-value>classpath*:applicationcontext-*.xml</param-value>
20
 	<listener>
22
 	<listener>
21
 		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
23
 		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
22
 	</listener>
24
 	</listener>
23
-	
25
+
26
+
24
 	<welcome-file-list>
27
 	<welcome-file-list>
25
 		<welcome-file>index.html</welcome-file>
28
 		<welcome-file>index.html</welcome-file>
26
 	</welcome-file-list>
29
 	</welcome-file-list>

+ 1 - 1
xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/index.html View File

1
-200
1
+i am alive.

+ 4 - 4
xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java View File

10
 
10
 
11
 
11
 
12
 /**
12
 /**
13
- * 任务Handler的一个Demo(Bean模式)
13
+ * 任务Handler示例(Bean模式)
14
  *
14
  *
15
  * 开发步骤:
15
  * 开发步骤:
16
- * 1、新建一个继承com.xxl.job.core.handler.IJobHandler的Java类
17
- * 2、该类被Spring容器扫描为Bean实例,如加“@Component”注解
18
- * 3、添加 “@JobHandler(value="自定义jobhandler名称")”注解,注解value值为自定义的JobHandler名称,该名称对应的是调度中心新建任务的JobHandler属性的值。
16
+ * 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”
17
+ * 2、注册到Spring容器:添加“@Component”注解,被Spring容器扫描为Bean实例
18
+ * 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。
19
  * 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
19
  * 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
20
  *
20
  *
21
  * @author xuxueli 2015-12-19 19:43:36
21
  * @author xuxueli 2015-12-19 19:43:36

+ 1 - 1
xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties View File

11
 ### xxl-job executor address
11
 ### xxl-job executor address
12
 xxl.job.executor.appname=xxl-job-executor-sample
12
 xxl.job.executor.appname=xxl-job-executor-sample
13
 xxl.job.executor.ip=
13
 xxl.job.executor.ip=
14
-xxl.job.executor.port=-1
14
+xxl.job.executor.port=9998
15
 
15
 
16
 ### xxl-job log path
16
 ### xxl-job log path
17
 xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
17
 xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler