Reputation: 1
Currently, I'm stuck with the integration of Spring Batch Admin (SBA) into our project cause of a problem I couldn't resolve. Hopefully, someone have an advice for me.
We use the sample SBA application (current version from Github) and added just a Tasklet. I upload Spring Batch descriptions (XMLs) via the /job-configuration.json API of SBA using. This works fine as expected. In the HTML pages of SBA, I see that the job registered and is launchable. It can be executed via the API (/jobs/{jobName}.json) and over the web interface.
The problem is, if I upload a new job, it is registered and launchable as well. But the job registered before becomes automatically "launchable = false". It couldn't be executed anymore.
I couldn't find any documentation about this behaviour nor any solution to avoid. Can you give me an direction what could be wrong?
Thanks in advance.
UPDATE
I couldn't get it working. My workaround is now
1) Upload the job data as XML file using the /job-configuration API method (POST, mutipart). This solves the problem that the job stays launchable also after multiple uploads.
2) I manually uploaded the XML files to WEB-INF\classes\META-INF\spring\batch\jobs, thus, the jobs are executable also after a re-sarted.
It's not nice, but works. I still appreciate any other more elegant solution.
Upvotes: 0
Views: 1030
Reputation: 21
You could register job factory to JobRegistry
@Autowired
private JobRegistry jobRegistry;
protected JobFactory factory;
@PostConstruct
public void init() throws DuplicateJobException {
factory = new JobFactory() {
@Override
public Job createJob() {
return job(); //your job creation logic
}
@Override
public String getJobName() {
return jobName();
}
};
jobRegistry.register(factory);
}
//for your own launcher
protected void run() throws Exception {
jobLauncher.run(factory.createJob(), parameters().toJobParameters());
}
Upvotes: 0