1. install openjob-server
1.1 docker pull openjob/openjob-server:latest
1.2 create .env file
1.3 AKKA_REMOTE_HOSTNAME=LocalIP
2. add jars
io.openjob.worker/openjob-worker-spring-boot-starter/1.0.7
3. support springboot3.x version
@Configuration
@ImportAutoConfiguration(value = {OpenjobWorkerAutoConfiguration.class})
public class OpenJobConfig {
}
4. config application.yml
5. static sharding
@Component
@Slf4j
public class ShardingAnnotationProcessor {
@Openjob("annotationShardingProcessor")
public ProcessResultshardingProcessor(JobContext jobContext) {
log.info("Sharding annotation processor execute success! shardingId={} shardingNum={} shardingParams={}",
jobContext.getShardingId(), jobContext.getShardingNum(), jobContext.getShardingParam());
log.info("jobContext={}", jobContext);
return ProcessResult.success();
}
}
6. more --> execute
网友评论