xxl-job使用

官網地址: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 的源碼就一次通過了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章