standalone spring batch jobs visible on the spring batch admin? - spring-batch

I would like to separate my jobs from the spring batch admin but to still be able to see the jobs in the admin page.
I would like 1 webapp to contain only the admin console and other webapps to contain a job. All the webapps will be deployed on the same weblogic server.
How can I make the jobs visible in the admin console even if the jobs are not in the same war file as the admin console ?
This is the only information I found on the documentation :
To add job executions from another process just execute a job (e.g.
from command line) against the same database that is used by Spring
Batch Admin. The UI picks up the meta data from the usual Spring Batch
tables.

Related

Spring batch process is getting invoked in BUILD step only via Jenkins pipeline

I have written a spring batch job and trying to deploy it via our jenkins pipeline.. This pipeline first build the code , create image and then deploy to kubernetese.
In my batch job, I am looking for a file in some specific directory and if the file is not there, our process sends an email.
I am observing one unique thing, whenever my Jenkins pipeline is running, after build step , I am receiving an email for the file unavailability whereas it should send an email or process the file based on its schedule. It seems like the process is getting triggered or invoked in build step only.
Is there any configuration that is required to invoke on the process on its schedule time only in spring batch and not while building ?
If you are using Spring Boot, you need to set the property spring.batch.job.enabled to false, because by default, Spring Boot executes all jobs in the application context on startup.

How to use Spring Cloud Dataflow to get Spring Batch Status

I have been using Spring Batch and my metadata is in DB2. I have been using Spring Batch admin API (jars) to look at the current status of various jobs and getting details about job, like number of items read, commit count, etc. Now, since Spring Batch Admin is moved to spring-data-cloud, how do look at these informations? Is there a good API set I could use?
Basically, in Spring Cloud Data flow, you first need to create Spring Cloud Task that will have your Batch application: See example [here][1]
With the help of Spring Cloud #EnableTaskLauncher you can get the current status of job, run the job, stop the job, etc.
You need to send TasKLauncherRequest for it.
See APIs of TaskLauncher
Edition:
To get spring batch status, u need to have first Task execution id of spring cloud task. Set<Long> getJobExecutionIdsByTaskExecutionId(long taskExecutionId); method of [TaskExplorer][3]
See Task Explorer for all the apis. With it, use JobExplorer to get status of jobs

Convert non-launchable job to launchable job in Spring Batch Admin

I have a Spring Batch job developed with Spring Boot (1.4.1.RELEASE).
It successfully runs from command line and writes job execution data to MySQL. It shows up as non-launchable job in Spring Batch Admin (2.0.0.M1, pointing to MySQL) and I can see job execution metrics.
Now I'd like to turn it into a launchable job so I can run it within Spring Batch Admin.
I wonder if anyone has done that before. The documentation has a section Add your Own Jobs For Launching. But it does not specify where to add the implementation jar(s) for the job?
Is it spring-batch-admin/WEB-INF/lib?
With Spring Boot, the non-launchable job is one big, all-in-one executable jar. Its dependencies overlap with Spring Batch Admin. For example, they both have spring-batch*.jar, spring*.jar but different versions.
Is there a way, like the job definition xml file, to keep them in separate contexts? Thank you.
Spring Batch Admin looks for your job definitions in src/main/resources/META-INF/spring/batch/jobs folder. You could add your job-definition.xml file in that folder and define your batch jobs in that xml.

Spring batch admin and starting Master/Slave jobs

Is it possible to configure spring batch admin to start Master and slave jobs. We have one process as master and 3-4 slave nodes.
Spring batch admin is running in separate JVM process but all spring batch jobs are using same batch db schema.
Spring Batch Admin only has the abilities to launch locally deployed jobs. So while you can launch a job that has master/slave configurations, the job that owns the master must be deployed locally. You could wire things up to launch remote jobs, but you'd have to wire things up yourself.
That being said, Spring XD (http://projects.spring.io/spring-xd/) is a distributed runtime that is able to launch jobs that are remotely deployed.

Reload a spring batch Job

We need to change an already running job. We should be able to push the job change without restarting the server.
Is it possible to reload a Spring batch job after the jobs / application context has been loaded.
The DefaultJobLoader allows you to reload the application context for your jobs.
Dynamic job deployment and editing of deployed job configurations (without requiring a server restart) is a feature we implemented in Trooper Batch profile (built on Spring Batch and Spring Batch admin). Screen shots are here : https://github.com/regunathb/Trooper/wiki/Writing-Batch-jobs-in-Trooper