ElasticJob报错Job conflict with register center

1
2
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名称相同的话,路径不能冲突

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@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();
}
}

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2021 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :