I am working on a Spring Batch application. I deployed this application on a production Linux server as ajar file that I runned as a normal jar application. My Spring Batch application is up and running, infact my UpdateInfoBatch-0.0.1-SNAPSHOT.jar seems to be up and running as process:
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
My application contains two Jobs definition scheduled at a specific time using a CRON expression:
/**
* 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);
}
}
Now I am asking if there are some way to interact with this running application in order to check if some errors occurs during the lasts executions of the jobs defined into this application. Is it possible to query my running application asking for jobs status or something like this?
CodePudding user response:
Yes, you can use Spring Batch database tables for this check the documentation here: https://docs.spring.io/spring-batch/docs/current/reference/html/schema-appendix.html