触发方式
XXL-JOB的任务可以通过Postman直接触发,curl脚本如下:
curl
curl --location 'http://localhost:9999/run' \
--header 'Content-Type: application/json' \
--data '{
"jobId": 1,
"executorHandler": "p2-aquarius-reconcile-dy",
"executorBlockStrategy": "COVER_EARLY",
"executorTimeout": 0,
"logId": 1,
"logDateTime": 1710919760260,
"glueType": "BEAN",
"glueUpdatetime": 1710919760260,
"broadcastIndex": 0,
"broadcastTotal": 0,
"executorParams": "00:00:00"
}'
只需要改demoJobHandler
和executorParams
参数,其他的都不用变。
demoJobHandler
:这里的job处理器替换成自己的就行。executorParams
:执行参数
源码
在XXL-JOB源码ExecutorBizTest
中有这段代码:
java
@Test
public void run(){
ExecutorBiz executorBiz = new ExecutorBizClient(addressUrl, accessToken);
// trigger data
final TriggerParam triggerParam = new TriggerParam();
triggerParam.setJobId(1);
triggerParam.setExecutorHandler("p2-aquarius-reference-audit-bill");
triggerParam.setExecutorParams(null);
triggerParam.setExecutorBlockStrategy(ExecutorBlockStrategyEnum.COVER_EARLY.name());
triggerParam.setGlueType(GlueTypeEnum.BEAN.name());
triggerParam.setGlueSource(null);
triggerParam.setGlueUpdatetime(System.currentTimeMillis());
triggerParam.setLogId(1);
triggerParam.setLogDateTime(System.currentTimeMillis());
// Act
final ReturnT<String> retval = executorBiz.run(triggerParam);
// Assert result
Assertions.assertNotNull(retval);
}
通过这段代码往下跟可以发现底层其实就是使用的HTTP工具完成的服务远程调用。最后拿出来就是上面的脚本。