WebSphere Application Server

JSR-352 (Java Batch) Post #58: batchManager Command Line Interface

By David Follis posted Wed September 11, 2019 09:21 AM

  
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 iTunesGoogle PlayStitcher, or use the link to the RSS feed
-----

Here’s a challenge – think of a clever and witty title involving the words “Command Line Interface”.  I spent a while trying to find some song lyrics that went with it, but I gave up.  Perhaps there’s an Italian opera that uses it and I don’t realize it. 

We’ve been talking about the REST interface that you can use to interact with the batch support inside a Liberty server.  That’s all well and good if you’ve got some application code that needs to reach into a server and submit a job or find out what happened to a job submitted earlier.  But what if you have a scripting environment or some JCL running on z/OS?  How would that use a REST interface to manage Liberty Java Batch jobs? 

Well, you could write a little client program that drove the REST interface.  It isn’t terribly difficult to do, which is why we did it for you.  Liberty ships a little program in the ‘bin’ folder called batchManager.  Underneath it is a Java program that parses a bunch of input parameters and constructs a proper HTTPS/REST request to submit a job or whatever other operation you need to do. 

Of necessity the parameter options can get a bit complicated because there is a lot you can do.  But if you just work with the - - help (two dashes, then ‘help’) option it will tell you all your choices. 

Having a lot of complicated options means you won’t likely actually issue the command yourself at a prompt.  The safer/easier thing to do is construct a small script that executes the CLI (that’s Command Line Interface when I’m too lazy to type it out) with whatever parameters you need. 

You’ll likely have a set of scripts that you use to submit jobs.  But you might also have a script that you use to purge older jobs.  Chron or some scheduling mechanism could kick that off and jobs older than whatever your standard retention period is would get purged automatically.  The CLI has all the fancy search options we talked about under the REST interface. 

So, find your bin directory and play around with the help and see all the different things you can do with batch from a script.
0 comments
5 views

Permalink