update document

2.1.2
xuxueli 5 years ago
parent f083bb2695
commit c042cb1504

@ -603,9 +603,7 @@ The task logic exist in the executor project as JobHandler,the develop steps as
- 1, create new java class implent com.xxl.job.core.handler.IJobHandler; - 1, create new java class implent com.xxl.job.core.handler.IJobHandler;
- 2, if you add @Component annotation on the top of the class name its will be managed as a bean instance by spring container; - 2, if you add @Component annotation on the top of the class name its will be managed as a bean instance by spring container;
- 3, add “@JobHandler(value=" customize jobhandler name")” annotationthe value stand for JobHandler name,it will be used as JobHandler property when create a new task in the schedule center. - 3, add “@JobHandler(value=" customize jobhandler name")” annotationthe value stand for JobHandler name,it will be used as JobHandler property when create a new task in the schedule center.
go and see DemoJobHandler in the xxl-job-executor-example project, as shown below
![输入图片说明](https://www.xuxueli.com/doc/static/xxl-job/images/img_oLlM.png "在这里输入图片标题")
#### Step 2:create task in schedule center #### Step 2:create task in schedule center
If you want learn more about configure item please go and sedd “Description of configuration item”select "BEAN模式" as run modeproperty JobHandler please fill in the value defined by @JobHande. If you want learn more about configure item please go and sedd “Description of configuration item”select "BEAN模式" as run modeproperty JobHandler please fill in the value defined by @JobHande.

@ -685,17 +685,23 @@ public XxlJobSpringExecutor xxlJobExecutor() {
- 执行参数:任务执行所需的参数; - 执行参数:任务执行所需的参数;
### 3.1 BEAN模式 ### 3.1 BEAN模式
任务逻辑以JobHandler的形式存在于“执行器”所在项目中,开发流程如下: 任务逻辑以注解方法的形式存在于“执行器”所在项目中任务方法底层会自动生成代理JobHandler,开发流程如下:
#### 步骤一执行器项目中开发JobHandler #### 步骤一执行器项目中开发Job方法
- 1、继承"IJobHandler"“com.xxl.job.core.handler.IJobHandler” - 1、在Spring Bean实例中开发Job方法方式格式要求为 "public ReturnT<String> execute(String param)"
- 2、注册到Spring容器添加“@Component”注解被Spring容器扫描为Bean实例 - 2、为Job方法添加注解 "@XxlJob(value="自定义jobhandler名称", init = "JobHandler初始化方法", destroy = "JobHandler销毁方法")"注解value值对应的是调度中心新建任务的JobHandler属性的值。
- 3、注册到执行器工厂添加“@JobHandler(value="自定义jobhandler名称")”注解注解value值对应的是调度中心新建任务的JobHandler属性的值。 - 3、执行日志需要通过 "XxlJobLogger.log" 打印执行日志;
- 4、执行日志需要通过 "XxlJobLogger.log" 打印执行日志;
可参考Sample示例执行器中的DemoJobHandler见下图
![输入图片说明](https://www.xuxueli.com/doc/static/xxl-job/images/img_oLlM.png "在这里输入图片标题") ```
// 可参考Sample示例执行器中的 "com.xxl.job.executor.service.jobhandler.SampleXxlJob" ,如下:
@XxlJob("demoJobHandler")
public ReturnT<String> execute(String param) {
XxlJobLogger.log("hello world.");
return ReturnT.SUCCESS;
}
```
#### 步骤二:调度中心,新建调度任务 #### 步骤二:调度中心,新建调度任务
参考上文“配置属性详细说明”对新建的任务进行参数配置,运行模式选中 "BEAN模式"JobHandler属性填写任务注解“@JobHandler”中定义的值 参考上文“配置属性详细说明”对新建的任务进行参数配置,运行模式选中 "BEAN模式"JobHandler属性填写任务注解“@JobHandler”中定义的值

Binary file not shown.

Before

Width:  |  Height:  |  Size: 380 KiB

@ -22,14 +22,14 @@ public class SampleXxlJob {
@XxlJob("demoJobHandler2") @XxlJob("demoJobHandler2")
public ReturnT<String> execute(String param) { public ReturnT<String> execute(String param) {
XxlJobLogger.log("222"); XxlJobLogger.log("hello world.");
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
} }
@XxlJob(value="demoJobHandler3", init = "init", destroy = "destory") @XxlJob(value="demoJobHandler3", init = "init", destroy = "destory")
public ReturnT<String> execute3(String param) { public ReturnT<String> execute3(String param) {
XxlJobLogger.log("333"); XxlJobLogger.log("hello world.");
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
} }

Loading…
Cancel
Save