Announcement Announcement Module
Collapse
No announcement yet.
How to stop a Spring Batch job using curl/json Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to stop a Spring Batch job using curl/json

    Hi, everyone.

    Using commands from unix and/or cygwin such as this:

    curl -v -d jobParameters= http://127.0.0.1:8080/MyWeb/batch/jobs/myJob.json

    ...I am able to launch a Spring Batch job. This basically emulates what one can do in the Spring Batch Admin web pages at a command line level.

    I learned all this from the reference manual yesterday:

    http://static.springsource.org/sprin.../reference.pdf

    It describes several such curl/json command patterns, but one command pattern it does not describe is how to stop and abandon Spring Batch jobs. How do I do that with curl/json?

    I've googled around, trying to find the syntax. I figure it's going to be something like "-d JobParameters=stop=true" or "-d JobParameters=status=abandon" or maybe "fail=true" instead "fail=false"?

    Where is all this documented at Spring please? Can't find it yet.

    Ben Ethridge

  • #2
    Hi Ben,

    When you send your command to start the job, you will receive a resource location. Send a DELETE to that address to stop the execution.

    So,

    curl -X DELETE <resource location>

    Phil

    Comment


    • #3
      Thanks. I have not tried your command above. Tinkering around with it using tcpmon and the Spring Batch Admin web gui, examining the http request structure from the gui, I found these commands to work:

      Stop a job (52406 is the Job Execution ID):

      curl -v -d "_method=DELETE&stop=stop" http://127.0.0.1:8080/MyWebApp/batch...ons/52406.json

      Abandon a job (52406 is the Job Execution ID):

      curl -v -d "_method=DELETE&abandon=abandon" http://127.0.0.1:8080/MyWebAppWeb/ba...ons/52406.json

      The key was the "_method=DELETE&stop=stop", and in quotes.

      It would probably be beneficial to others if someone on the Spring team could add these to the documentation that currently only shows how to launch jobs via curl.
      Ben

      Comment


      • #4
        Originally posted by benethridge View Post
        It would probably be beneficial to others if someone on the Spring team could add these to the documentation that currently only shows how to launch jobs via curl.
        Ben
        This is a fair request, you should fill in a JIRA to make it easier to track.

        Comment

        Working...
        X