Registry Center Configuration

Prefix: elasticjob.reg-center

Configuration:

Property nameRequired
server-listsYes
namespaceYes
base-sleep-time-millisecondsNo
max-sleep-time-millisecondsNo
max-retriesNo
session-timeout-millisecondsNo
connection-timeout-millisecondsNo
digestNo

Reference:

YAML

  1. elasticjob:
  2. regCenter:
  3. serverLists: localhost:6181
  4. namespace: elasticjob-lite-springboot

Properties

  1. elasticjob.reg-center.namespace=elasticjob-lite-springboot
  2. elasticjob.reg-center.server-lists=localhost:6181

Job Configuration

Prefix: elasticjob.jobs

Configuration:

Property nameRequired
elasticJobClass / elasticJobTypeYes
cronNo
jobBootstrapBeanNameNo
sharding-total-countYes
sharding-item-parametersNo
job-parameterNo
monitor-executionNo
failoverNo
misfireNo
max-time-diff-secondsNo
reconcile-interval-minutesNo
job-sharding-strategy-typeNo
job-executor-service-handler-typeNo
job-error-handler-typeNo
job-listener-typesNo
descriptionNo
propsNo
disabledNo
overwriteNo

“elasticJobClass” and “elasticJobType” are mutually exclusive.

If cron was configured, the job will be created as a ScheduleJobBootstrap. The Starter will start scheduling when application is ready. Otherwise, the job will be created as a OneOffJobBootstrap with a name specified by “jobBootstrapBeanName”. It requires manual injection and execution.

Reference:

YAML

  1. elasticjob:
  2. jobs:
  3. simpleJob:
  4. elasticJobClass: org.apache.shardingsphere.elasticjob.lite.example.job.SpringBootSimpleJob
  5. cron: 0/5 * * * * ?
  6. shardingTotalCount: 3
  7. shardingItemParameters: 0=Beijing,1=Shanghai,2=Guangzhou
  8. scriptJob:
  9. elasticJobType: SCRIPT
  10. cron: 0/10 * * * * ?
  11. shardingTotalCount: 3
  12. props:
  13. script.command.line: "echo SCRIPT Job: "
  14. manualScriptJob:
  15. elasticJobType: SCRIPT
  16. jobBootstrapBeanName: manualScriptJobBean
  17. shardingTotalCount: 9
  18. props:
  19. script.command.line: "echo Manual SCRIPT Job: "

Properties

  1. elasticjob.jobs.simpleJob.elastic-job-class=org.apache.shardingsphere.elasticjob.lite.example.job.SpringBootSimpleJob
  2. elasticjob.jobs.simpleJob.cron=0/5 * * * * ?
  3. elasticjob.jobs.simpleJob.sharding-total-count=3
  4. elasticjob.jobs.simpleJob.sharding-item-parameters=0=Beijing,1=Shanghai,2=Guangzhou
  5. elasticjob.jobs.scriptJob.elastic-job-type=SCRIPT
  6. elasticjob.jobs.scriptJob.cron=0/5 * * * * ?
  7. elasticjob.jobs.scriptJob.sharding-total-count=3
  8. elasticjob.jobs.scriptJob.props.script.command.line=echo SCRIPT Job:
  9. elasticjob.jobs.manualScriptJob.elastic-job-type=SCRIPT
  10. elasticjob.jobs.manualScriptJob.job-bootstrap-bean-name=manualScriptJobBean
  11. elasticjob.jobs.manualScriptJob.sharding-total-count=3
  12. elasticjob.jobs.manualScriptJob.props.script.command.line=echo Manual SCRIPT Job:

Event Trace Configuration

Prefix: elasticjob.tracing

Property nameOptionsRequired
typeRDBNo

RDB is the only supported type at present. If Spring IoC container contained a bean of DataSource and RDB was set in configuration, an instance of TracingConfiguration will be created automatically.

Reference:

YAML

  1. elasticjob:
  2. tracing:
  3. type: RDB

Properties

  1. elasticjob.tracing.type=RDB

Dump Job Info Configuration

Prefix: elasticjob.dump

Property nameDefault valueRequired
enabledtrueNo
portYes

Designate a port as dump port in configurations. The Spring Boot Starter will enable dumping automatically. If the port for job dump was missing, dump won’t be enabled.

Reference:

YAML

  1. elasticjob:
  2. dump:
  3. port: 9888

Properties

  1. elasticjob.dump.port=9888