This post is part of a series delving into the details of the JSR-352 (Java Batch) specification. Each post examines a very specific part of the specification and looks at how it works and how you might use it in a real batch application.To start at the beginning, follow the link to the first post.
The next post in the series is here
.This series is also available as a podcast on iTunes, Google Play, Stitcher, or use the link to the RSS feed.
Back when we were just discussing the JSR-352 specification we went over the
JobOperator interface. That’s the API the specification provides to allow you to start a job, stop a job, restart a stopped/failed job, and get information about running jobs and jobs that aren’t running.
JobOperator interface is great if you have running application code that needs to spin off some batch processing as part of whatever the application is already doing. But in an Enterprise environment you are likely to have some sort of batch scheduler that submits production jobs automatically. How would something outside of a server providing Java Batch capabilities get jobs started?
Well you can certainly invent your own way to drive work into the server and call
JobOperator, but we thought we would help you out with that by providing a REST interface for batch. The REST interface essentially (although not actually) wraps the
JobOperator interface and allows you to do all the same things, plus some extras.
The exact operation you want to perform is controlled by the REST verb (GET, POST, PUT, DELETE) and the URI used to access it. You can also provide parameters to the specific service as a JSON string parameter on the REST request.
We haven’t talked about security yet, so for now we’ll just say that the REST interface is protected so not just anybody can submit or manage batch jobs.
In subsequent posts we’ll take a look at some of the specific capabilities of the REST interface, although we won’t be going into intense detail. The Knowledge Center provides complete documentation about the API (in all its versions).
A great way to explore and learn about the batch REST interface (and any other enabled REST interfaces in Liberty) is to use the apiDiscovery feature. This makes any REST interface defined with appropriate Swagger documentation accessible via a browser. Just direct your browser at https://host:https_port/ibm/api/explorer for the appropriate host/port of your server and explore the available REST APIs. You can use it to drive the interface and get the exact required syntax (appropriate for use via cURL, if you like).