|
@@ -94,20 +94,35 @@
|
94
|
94
|
<textarea id="demoCode" style="display:none;" >
|
95
|
95
|
package com.xxl.job.service.handler;
|
96
|
96
|
|
|
97
|
+import java.util.concurrent.TimeUnit;
|
|
98
|
+
|
97
|
99
|
import org.slf4j.Logger;
|
98
|
100
|
import org.slf4j.LoggerFactory;
|
|
101
|
+import org.springframework.stereotype.Service;
|
99
|
102
|
|
100
|
103
|
import com.xxl.job.client.handler.IJobHandler;
|
|
104
|
+import com.xxl.job.client.handler.IJobHandler.JobHandleStatus;
|
|
105
|
+import com.xxl.job.client.handler.annotation.JobHander;
|
101
|
106
|
|
102
|
107
|
public class DemoJobHandler extends IJobHandler {
|
103
|
108
|
private static transient Logger logger = LoggerFactory.getLogger(DemoJobHandler.class);
|
104
|
109
|
|
105
|
110
|
@Override
|
106
|
111
|
public JobHandleStatus handle(String... params) throws Exception {
|
107
|
|
- logger.info("demo run success...");
|
|
112
|
+ for (int i = 0; i < 5; i++) {
|
|
113
|
+ TimeUnit.SECONDS.sleep(1);
|
|
114
|
+ logger.info("handler run:{}", i);
|
|
115
|
+ }
|
108
|
116
|
return JobHandleStatus.SUCCESS;
|
109
|
117
|
}
|
|
118
|
+
|
|
119
|
+ public static void main(String[] args) {
|
|
120
|
+ System.out.println(DemoJobHandler.class.getName());
|
|
121
|
+ System.out.println(DemoJobHandler.class);
|
|
122
|
+ }
|
|
123
|
+
|
110
|
124
|
}
|
|
125
|
+
|
111
|
126
|
</textarea>
|
112
|
127
|
|
113
|
128
|
<@netCommon.comAlert />
|