ElasticJob报错Job conflict with register center

com.dangdang.ddframe.job.exception.JobConfigurationException: Job conflict with register center.
  The job 'DownloadReconcileTask' in register center's class is 'cn.appblog.mall.pay.job.alipay.task.DownloadReconcileTask', your job class is 'cn.appblog.mall.pay.job.wechatpay.task.DownloadReconcileTask'

原因:注入的SimpleJob Bean名称相同的话,路径不能冲突

@Configuration
public class MyJobConfig {

    @Resource
    private ZookeeperRegistryCenter regCenter;

    @Bean
    public SimpleJob simpleJob() {
        return new DownloadReconcileTask();  //Bean名称相同,路径冲突
    }

    @Bean(initMethod = "init")
    public JobScheduler simpleJobScheduler(final SimpleJob simpleJob, @Value("${downloadReconcileJob.cron}") final String cron,
                                           @Value("${downloadReconcileJob.shardingTotalCount}") final int shardingTotalCount,
                                           @Value("${downloadReconcileJob.shardingItemParameters}") final String shardingItemParameters,
                                           @Value("${downloadReconcileJob.description}") final String description) {

        return new SpringJobScheduler(simpleJob, regCenter, getLiteJobConfiguration(simpleJob.getClass(), cron, shardingTotalCount, shardingItemParameters, description));
    }

    private LiteJobConfiguration getLiteJobConfiguration(final Class<? extends SimpleJob> jobClass, final String cron, final int shardingTotalCount, final String shardingItemParameters, final String description) {

        return LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder(
                jobClass.getSimpleName(), cron, shardingTotalCount).shardingItemParameters(shardingItemParameters).description(description).build(), jobClass.getCanonicalName())).overwrite(true).build();
    }
}

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/27/elasticjob-error-job-conflict-with-register-center/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
ElasticJob报错Job conflict with register center
com.dangdang.ddframe.job.exception.JobConfigurationException: Job conflict with register center. The job 'DownloadReconcileTask' in regi……
<<上一篇
下一篇>>
文章目录
关闭
目 录