触发方式

XXL-JOB的任务可以通过Postman直接触发,curl脚本如下:

curl --location 'http://localhost:9999/run' \
--header 'Content-Type: application/json' \
--data '{
    "jobId": 1,
    "executorHandler": "demoJobHandler",
    "executorBlockStrategy": "COVER_EARLY",
    "executorTimeout": 0,
    "logId": 1,
    "logDateTime": 1710919760260,
    "glueType": "BEAN",
    "glueUpdatetime": 1710919760260,
    "broadcastIndex": 0,
    "broadcastTotal": 0,
    "executorParams": "00:00:00"
}'

只需要改executorHandlerexecutorParams参数,其他的都不用变。

  • executorHandler:这里的job处理器替换成自己的就行。
  • executorParams:执行参数

源码

在XXL-JOB源码ExecutorBizTest中有这段代码:

    @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工具完成的服务远程调用。最后拿出来就是上面的脚本。

引流

GitFlowPlus

GitFlowPlus分支管理IDEA插件

layering-cache

layering-cache 多级缓存开发框架

本站无任何商业行为
个人在线分享 » 【XXL-JOB】通过Postman调试本地任务
E-->