-----------------------------------1. 创建注册中心的对象-------------------------------------------------------------
ZookeeperConfiguration zkConfig = new ZookeeperConfiguration(ZOOKEEPER_CONNECTION_STRING, JOB_NAMESPACE);
CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(zkConfig);
regCenter.init();
-----------------------------------2. 作业事件配置--------------------------------------------------------------------
BasicDataSource dataSource = new BasicDataSource(); //创建数据源
................... //数据源的设置
//作业数据库事件配置
JobEventConfiguration jobEventConfig = new JobEventRdbConfiguration(dataSource);
 
 
 
------------------------------------3.创建作业核心配置--------------------------------------------------------------
//创建简单作业配置构建器.
JobCoreConfiguration.Builder builder = JobCoreConfiguration.newBuilder("javaSimpleJob", "0/5 * * * * ?", 3) ;
//设置分片参数
builder.shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou") ;
 
//创建作业核心配置
JobCoreConfiguration coreConfig = builder.build() ;
 
------------------------------------4.创建作业类型配置-------------------------------------------------------------
//创建作业类型配置
SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(coreConfig, JavaSimpleJob.class.getCanonicalName());
 
------------------------------------5.创建 Lite作业配置---------------------------------------------------------------
LiteJobConfiguration.Builder jobBuilder = LiteJobConfiguration.newBuilder(simpleJobConfig) ;
LiteJobConfiguration liteJobConfiguration jobBuilder.build() ;
 
-----------------------------------6.创建调度器-----------------------------------------------------------------------
JobScheduler jobScheduler = new JobScheduler(regCenter, liteJobConfiguration , jobEventConfig) ;
 
-----------------------------------7.启动调度器----------------------------------------------------------------------

相关文章:

  • 2021-11-05
  • 2021-10-08
  • 2021-09-19
  • 2021-11-28
  • 2021-04-01
  • 2022-01-09
  • 2022-12-23
猜你喜欢
  • 2021-06-23
  • 2021-11-14
  • 2021-05-20
  • 2022-12-23
  • 2021-07-04
  • 2021-12-30
  • 2021-09-12
相关资源
相似解决方案