3

I have a requirement where i have created a custom UI for spring-batch monitoring using the spring-batch-admin JSON api. I have a requirement where i dont want to allow the user to start job when an instance of that job is currently under progress.

Is there any REST Url which can give me a status of a job instance whether a job is in progress or not ?

Is there any way to develop a custom REST url to provide this functionality.

Kindly help.

user2361591
  • 153
  • 1
  • 14

1 Answers1

0

Never used this API, but from this site: http://docs.spring.io/spring-batch-admin/reference/json.html

You can get the status of the last job (so, the one running if there is one running) with http://localhost:8080/sprin-batch-admin-sample/batch/jobs/job1.json (replacing with job1 your actual job name and server). The parameter lastJobExecutionStatus should be STARTING, STARTED or STOPPING if it's still running.

List of possible status (check your batch version): http://docs.spring.io/spring-batch/apidocs/org/springframework/batch/core/BatchStatus.html#STARTING

Note that the job might crash, leaving it in a state like STARTED.

EDIT: Server-side, you can create a rest endpoint and use the SynchronizedJobLauncher class which "synchronizes jobs globally so that only one execution of a given Job can be active at once." (http://docs.spring.io/spring-batch-admin/apidocs/org/springframework/batch/admin/launch/package-summary.html). There are many resources on how to create a rest endpoint for json, and how to inject a JobLauncher.

Other possibilities are listed here: http://docs.spring.io/spring-batch-admin/reference/reference.xhtml

Asoub
  • 2,273
  • 1
  • 20
  • 33
  • If i want to add additional capabilites into the rest urls provided by the spring-batch-admin , how would i do so ? – user2361591 Sep 20 '16 at 05:51
  • You can either change your Spring configuration server side to change the json API behavior (second line in my edit) or create your own rest endpoint in Java server-side. – Asoub Sep 20 '16 at 07:01