Announcement Announcement Module
No announcement yet.
Spring Batch Admin JSON - async ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Batch Admin JSON - async ?

    I have incorporated Spring Batch Admin into our web app, and now want to use the JSON Restful interface to launch a Job

    All seems to be working well, except I was expecting the HTTP Post that launches a Job to return immediately with a JSON response giving the resource that could be polled to see when the job has finished. However what seems to be happening is the POST is not returning until the Job has completed, so I see

    {"jobExecution" : { 
        "resource" : "http://localhost:8080/MyApp/batch/jobs/executions/0.json",
        "id" : "0",
        "name" : "myJob",
        "status" : "COMPLETED",
        "startTime" : "14:37:58",
        "duration" : "00:00:27",
        "exitCode" : "COMPLETED",
        "exitDescription" : "",
        "jobInstance" : { "resource" : "http://localhost:8080/MyApp/batch/jobs/myJob/0.json" },
        "stepExecutions" : {
            "step1" : { 
            	"resource" : "http://localhost:8080/MyApp/batch/jobs/executions/0/steps/0.json",
            	"status" : "COMPLETED",
     			"exitCode" : "COMPLETED"
    Isn't this supposed to work asynchronously ? as my job may take many minutes to complete, and won't the HTTP connection timeout ?

  • #2
    What is the URL you are you hitting?


    • #3
      The URL we're hitting is a HTTP Post to :-


      (this is from memory - as not at work today)

      This was following the section in

      As I have embedded Spring Batch Admin in our existing webapp, I have 2 Servlet/Dispatchers
      1) Our app mapping "/" to our application's Spring MVC / Webflow dispatcher
      2) The Batch Servlet mapped to /batch/*

      Unless the servlet is intelligent and waits synchronously for a number of seconds before going async
      Last edited by PeteTh; Dec 15th, 2012, 12:32 PM.


      • #4
        What task executor are you using (jobLauncherTaskExecutor)? If this is a synchronous task executor, the thread would wait, however that is not the default...


        • #5
          Yes it was my bad - I had inadvertently overridden the jobLauncher bean that is supplied in Spring Batch Admin \META-INF\spring\batch\bootstrap\manager\execution-context.xml with a default SimpleJobLauncher (which I realise now is synchronous).

          I think this happened, as we got Spring Batch alone working first from a Unit Testing point of view, then added Spring Batch Admin. Now in some cases we're using our Beans instead of the ones in Spring Batch Admin. It is all working but a little confusing to understand which Beans are overriding etc.