xuxueli / xxl-job

A distributed task scheduling framework.(分布式任务调度平台XXL-JOB)
http://www.xuxueli.com/xxl-job/
GNU General Public License v3.0
27.46k stars 10.86k forks source link

版本2.0.2,xxl-job registry error,无法注册 #610

Closed lianghuiyuan closed 5 years ago

lianghuiyuan commented 5 years ago

Which version of XXL-JOB do you using?

V2.0.2

Expected behavior

EXECUTOR xxl-job registry success

Actual behavior

EXECUTOR xxl-job registry error

Steps to reproduce the behavior

你好,我通过IDEA Maven打jar包,在服务器通过命令nohup java -jar ./xxl-job-admin-2.0.2-SNAPSHOT.jar -Xmx128m &部署, 端口映射的是8085,xxl-job-admin配置是:

### web
server.port=8085
server.context-path=/xxl-job-admin

### resources
spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:/static/

### freemarker
spring.freemarker.templateLoaderPath=classpath:/templates/
spring.freemarker.suffix=.ftl
spring.freemarker.charset=UTF-8
spring.freemarker.request-context-attribute=request
spring.freemarker.settings.number_format=0.##########

### mybatis
mybatis.mapper-locations=classpath:/mybatis-mapper/*Mapper.xml

### xxl-job, datasource
spring.datasource.url=jdbc:mysql://my.mysql.server.ip:3306/xxl-job?Unicode=true&characterEncoding=UTF-8&useSSL=false
spring.datasource.username=myusername
spring.datasource.password=mypassword
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource
spring.datasource.tomcat.max-wait=10000
spring.datasource.tomcat.max-active=30
spring.datasource.tomcat.test-on-borrow=true

### xxl-job email
spring.mail.host=smtp.qq.com
spring.mail.port=25
spring.mail.username=12345678@qq.com
spring.mail.password=123456
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true

### xxl-job login
xxl.job.login.username=admin
xxl.job.login.password=123456

### xxl-job, access token
xxl.job.accessToken=

### xxl-job, i18n (default empty as chinese, "en" as english)
xxl.job.i18n=

在IDEA中的EXECUTOR项目xxl-job配置是:

xxl:
  job:
    admin:
      addresses: http://my.xxl-job.server.ip:8085/xxl-job-admin
    executor:
      appname: fiance-executor-new
      ip:
      port: 7777
      logpath:  /data/applogs/xxl-job/jobhandler/
      logretentiondays: -1
    accessToken:

项目能够正常启动,同样的配置,使用xxl-job-executor-sample-springbootEXECUTOR可以在xxl-job-admin中注册成功,但是使用我的项目EXECUTOR却在xxl-job-admin中注册失败。

我的项目xxl-job配置初始化代码

    @Bean(initMethod = "start", destroyMethod = "destroy")
    public XxlJobExecutor xxlJobExecutor() {
        logger.info(">>>>>>>>>>> xxl-job config init.");
        XxlJobExecutor xxlJobExecutor = new XxlJobExecutor();
        xxlJobExecutor.setIp(ip);
        xxlJobExecutor.setPort(port);
        xxlJobExecutor.setAppName(appname);
        xxlJobExecutor.setAdminAddresses(addresses);
        xxlJobExecutor.setLogPath(logpath);
        xxlJobExecutor.setAccessToken(accessToken);
        xxlJobExecutor.setLogRetentionDays(logRetentionDays);
        return xxlJobExecutor;
    }

注册失败报错信息:

16:37:29.078 logback [Thread-24] INFO  c.x.j.c.t.ExecutorRegistryThread - >>>>>>>>>>> xxl-job registry error, registryParam:RegistryParam{registGroup='EXECUTOR', registryKey='fiance-executor-new', registryValue='192.168.3.7:7777'}
java.lang.RuntimeException: Client-error:unknown code for readObject at 0x63 (c)
    at com.xxl.job.core.rpc.netcom.NetComClientProxy$1.invoke(NetComClientProxy.java:65)
    at com.sun.proxy.$Proxy114.registry(Unknown Source)
    at com.xxl.job.core.thread.ExecutorRegistryThread$1.run(ExecutorRegistryThread.java:57)
    at java.lang.Thread.run(Thread.java:745)
sunhao91 commented 5 years ago

注意看demo。。。

初始化执行器 换成 XxlJobSpringExecutor

我昨晚也被坑了好久~

lianghuiyuan commented 5 years ago

@sunhao91 谢谢你! 确实是类实例化的问题。 首先确定依赖的xxl-job的版本是2.0.1及以上,然后正确初始化代码如下:

    @Bean(initMethod = "start", destroyMethod = "destroy")
    public XxlJobSpringExecutor xxlJobExecutor() {
        logger.info(">>>>>>>>>>> xxl-job config init.");
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
        xxlJobSpringExecutor.setIp(ip);
        xxlJobSpringExecutor.setPort(port);
        xxlJobSpringExecutor.setAppName(appname);
        xxlJobSpringExecutor.setAdminAddresses(addresses);
        xxlJobSpringExecutor.setLogPath(logpath);
        xxlJobSpringExecutor.setAccessToken(accessToken);
        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
        return xxlJobSpringExecutor;
    }