我正在開發一個 Spring Batch 應用程式。我將此應用程式部署在生產 Linux 服務器上作為我作為普通 jar 應用程式運行的 ajar 檔案。我的 Spring Batch 應用程式已啟動并運行,事實上我的UpdateInfoBatch-0.0.1-SNAPSHOT.jar似乎已啟動并作為行程運行:
webadmin@webadmin.myserver.it [~]# ps aux | grep java
webadmin 4677 0.1 3.2 10255180 809528 ? Sl Nov17 12:10 java -jar UpdateInfoBatch-0.0.1-SNAPSHOT.jar
webadmin 5152 0.0 0.0 112812 980 pts/1 S 09:58 0:00 grep --color=auto java
我的應用程式包含使用 CRON 運算式在特定時間安排的兩個作業定義:
/**
* This bean schedules and runs our Spring Batch job.
*/
@Component
@Profile("!test")
public class SpringBatchExampleJobLauncher {
private static final Logger LOGGER = LoggerFactory.getLogger(SpringBatchExampleJobLauncher.class);
@Autowired
@Qualifier("launcher")
private JobLauncher jobLauncher;
@Autowired
@Qualifier("updateNotaryDistrictsJob")
private Job updateNotaryDistrictsJob;
@Autowired
@Qualifier("updateNotaryListInfoJob")
private Job updateNotaryListInfoJob;
@Scheduled(cron = "${cron.expresion.runUpdateNotaryListInfoJob}")
public void runUpdateNotaryListInfoJob() {
LOGGER.info("SCHEDULED run of updateNotaryListInfoJob STARTED");
Map<String, JobParameter> confMap = new HashMap<>();
confMap.put("time", new JobParameter(System.currentTimeMillis()));
JobParameters jobParameters = new JobParameters(confMap);
try {
jobLauncher.run(updateNotaryListInfoJob, jobParameters);
}catch (Exception ex){
LOGGER.error(ex.getMessage());
}
}
@Scheduled(cron = "${cron.expresion.runUpdateNotaryDistrictJob}")
public void runUpdateNotaryDistrictsJob() {
LOGGER.info("SCHEDULED run of updateNotaryDistrictsJob STARTED");
Map<String, JobParameter> confMap = new HashMap<>();
confMap.put("time", new JobParameter(System.currentTimeMillis()));
JobParameters jobParameters = new JobParameters(confMap);
try {
jobLauncher.run(updateNotaryDistrictsJob, jobParameters);
}catch (Exception ex){
LOGGER.error(ex.getMessage());
}
}
private JobParameters newExecution() {
Map<String, JobParameter> parameters = new HashMap<>();
JobParameter parameter = new JobParameter(new Date());
parameters.put("currentTime", parameter);
return new JobParameters(parameters);
}
}
現在我問是否有某種方法可以與這個正在運行的應用程式互動,以檢查在定義到這個應用程式中的作業的最后執行期間是否發生了一些錯誤。是否可以查詢我正在運行的應用程式,詢問作業狀態或類似的資訊?
uj5u.com熱心網友回復:
是的,您可以使用 Spring Batch 資料庫表來檢查這里的檔案:https : //docs.spring.io/spring-batch/docs/current/reference/html/schema-appendix.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/362861.html
