官网地址:https://github.com/xuxueli/xxl-job
公司使用的xxl-job:http://192.168.173.100:90/lite/xxl/xxl-job-spring-boot-starter
参考搭建xxl-job博客:https://www.cnblogs.com/ysocean/p/10541151.html
xxl-admin登录:http://192.168.173.201:8030/jobgroup
注意:首先要新建执行器管理器,然后新建定时任务。
1.job executor配置admin地址:
xxl:
job:
admin:
addresses: http://192.168.158.107:8080/xxl-job-admin
# addresses: http://192.168.173.201:8030/
如果配置成本地的,http://192.168.158.107:8080/xxl-job-admin,就可以执行。
但是如果配置成仓配测试环境的 http://192.168.173.201:8030/,执行定时任务就会出现执行器地址为空。
2. 启动执行器DasCorpWebApplication,能启动成功,但是端口被占用了。同时发现:任务已经注册了。
"C:\Program Files\Java\jdk1.8.0_201\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63275,suspend=y,server=n -javaagent:....." com.runlion.iot.corp.DasCorpWebApplication
Connected to the target VM, address: '127.0.0.1:63275', transport: 'socket'
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.2.7.RELEASE)
2020-06-03 14:53:48 [TraceId:] [main] INFO c.r.i.c.DasCorpWebApplication - Starting DasCorpWebApplication on USER-20181226QH with PID 25128 (E:\runlion-proj\iot-das\das-corp\das-corp-web\target\classes started by Administrator in E:\runlion-proj\iot-das)
2020-06-03 14:53:48 [TraceId:] [main] DEBUG c.r.i.c.DasCorpWebApplication - Running with Spring Boot v2.2.7.RELEASE, Spring v5.2.6.RELEASE
2020-06-03 14:53:48 [TraceId:] [main] INFO c.r.i.c.DasCorpWebApplication - The following profiles are active: dev
2020-06-03 14:53:50 [TraceId:] [main] INFO o.s.b.w.e.t.TomcatWebServer - Tomcat initialized with port(s): 8099 (http)
2020-06-03 14:53:50 [TraceId:] [main] INFO o.a.c.h.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8099"]
2020-06-03 14:53:50 [TraceId:] [main] INFO o.a.c.c.StandardService - Starting service [Tomcat]
2020-06-03 14:53:50 [TraceId:] [main] INFO o.a.c.c.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.34]
2020-06-03 14:53:50 [TraceId:] [main] INFO o.a.c.c.C.[.[.[/] - Initializing Spring embedded WebApplicationContext
2020-06-03 14:53:50 [TraceId:] [main] INFO o.s.w.c.ContextLoader - Root WebApplicationContext: initialization completed in 1459 ms
2020-06-03 14:53:51 [TraceId:] [main] INFO o.s.s.c.ThreadPoolTaskExecutor - Initializing ExecutorService 'taskExecutor'
2020-06-03 14:53:57 [TraceId:] [main] INFO c.r.i.j.c.XxlJobConfig - >>>>>>>>>>> xxl-job config init.
2020-06-03 14:53:57 [TraceId:] [Thread-5] INFO c.x.j.c.s.EmbedServer - >>>>>>>>>>> xxl-job remoting server start success, nettype = class com.xxl.job.core.server.EmbedServer, port = 9002
2020-06-03 14:53:57 [TraceId:] [main] INFO c.x.j.c.e.XxlJobExecutor - >>>>>>>>>>> xxl-job register jobhandler success, name:das2JobHandler, jobHandler:com.xxl.job.core.handler.impl.MethodJobHandler@764fffa0[class com.runlion.iot.corp.job.Das2JobHandler#das2JobHandler]
2020-06-03 14:53:57 [TraceId:] [main] INFO c.x.j.c.e.XxlJobExecutor - >>>>>>>>>>> xxl-job register jobhandler success, name:opcJobHandler, jobHandler:com.xxl.job.core.handler.impl.MethodJobHandler@35145874[class com.runlion.iot.corp.job.OpcJobHandler#opcJobHandler]
2020-06-03 14:53:57 [TraceId:] [main] INFO o.a.c.h.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8099"]
Exception in thread "Thread-10" java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
3. 手动指定执行器地址:192.168.158.107:9002。
执行任务,仍报错:msg:xxl-rpc remoting error(no protocol: 192.168.158.107:9002/run), for url : 192.168.158.107:9002/run。
任务日志:
任务触发类型:手动触发
调度机器:192.168.173.201
执行器-注册方式:手动录入
执行器-地址列表:[192.168.158.107:9002]
路由策略:第一个
阻塞处理策略:单机串行
任务超时时间:0
失败重试次数:0
>>>>>>>>>>>触发调度<<<<<<<<<<<
触发调度:
address:192.168.158.107:9002
code:500
msg:xxl-rpc remoting error(no protocol: 192.168.158.107:9002/run), for url : 192.168.158.107:9002/run
这个问题:由于jar包不同导致。
我本地拉下来的xxl-job是2.2.1版本的,启动xxl-job-admin。
执行器可以正常执行。
如果配置成仓配项目使用的xxl-job-admin就报错。
参考:https://blog.csdn.net/zhengzhaoyang122/article/details/105729062
【问题描述】:msg:xxl-rpc remoting error(no protocol: 127.0.0.1:9999/run), for url ;
【解决方案】:我们项目里面引入了 xxl-job 的 jar 包是 2.1.2,xxl-job 项目的源码,领导发到了群里,我就直接拿过来解压使用了,就发现如上问题,一直调试发现就是项目源码的问题,百思不得其解。最后想想是不是版本有问题,最后发现,源码的版本是 2.1.1,最终导致如上 rpc调用问题。因此重新下来了 2.1.2 的源码就一次通过了。