Results 1 to 5 of 5

Thread: Spring Batch Admin JSON - async ?

Hybrid View

  1. #1

    Default 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

    Code:
    {"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. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    366

    Default

    What is the URL you are you hitting?
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  3. #3

    Default

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

    http://localhost:8080/spring-batch-a...obs/myJob.json

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

    This was following the section in http://static.springsource.org/sprin....html#JSON_API

    NOTE:
    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 at 11:32 AM.

  4. #4
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    366

    Default

    What task executor are you using (jobLauncherTaskExecutor)? If this is a synchronous task executor, the thread would wait, however that is not the default...
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  5. #5

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •