sunkai-cai opened a new pull request, #2103:
URL: https://github.com/apache/shardingsphere-elasticjob/pull/2103
Related to #1445.
Changes proposed in this pull request:
- add annotation interface `@ElasticJobConfiguration`
- add JobAnnotationBuilder
- `ScheduleJobBootstrap` and `OneOffJobBootstrap` support annotation job
- add job scanner in the spring
//Java example:
```
@ElasticJobConfiguration(
cron = "0/5 * * * * ?",
jobName = "SimpleTestJobFirst",
shardingTotalCount = 3,
shardingItemParameters = "0=Beijing,1=Shanghai,2=Guangzhou",
jobListenerTypes = {"NOOP", "LOG"},
props = {
@ElasticJobProp(key = "print.title", value = "test title"),
@ElasticJobProp(key = "print.content", value = "test
content")
}
)
public class SimpleTestJob implements CustomJob {
@Override
public void execute(final ShardingContext shardingContext) {
}
}
```
```
public final class JavaMain {
.....
public static void main(final String[] args) throws IOException {
CoordinatorRegistryCenter regCenter = setUpRegistryCenter();
(new ScheduleJobBootstrap(regCenter,new SimpleTestJob())).schedule();
}
.....
}
```
//spring example:
```
package org.apache.shardingsphere.elasticjob.job;
@ElasticJobConfiguration(
cron = "0/5 * * * * ?",
jobName = "SimpleTestJobFirst",
shardingTotalCount = 3,
shardingItemParameters = "0=Beijing,1=Shanghai,2=Guangzhou",
jobListenerTypes = {"NOOP", "LOG"},
props = {
@ElasticJobProp(key = "print.title", value = "test title"),
@ElasticJobProp(key = "print.content", value = "test
content")
}
)
public class SimpleTestJob implements CustomJob {
@Override
public void execute(final ShardingContext shardingContext) {
}
}
```
```
@SpringBootApplication
@ElasticJobScan("org.apache.shardingsphere.elasticjob.job")
public class SpringBootMain {
public static void main(final String[] args) {
SpringApplication.run(SpringBootMain.class, args);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]