WebSphere Application Server & Liberty

JSR-352 (Java Batch) Post #63: Enterprise Scheduler Integration

By David Follis posted Wed October 16, 2019 07:51 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

If you’re going to run production batch applications, you’re going to need something to coordinate and manage them.  There are a bunch of different ways to do this including several software packages you can use. 

The question for today is:  How would you integrate Java Batch applications running inside a Liberty server with whatever your existing Enterprise Scheduler is? 

Enterprise Schedulers run things.  Probably a script or something like one.  On z/OS they generally submit JCL.

Java Batch applications are available to run inside a Liberty server.  How do we connect the two? 

Well, one way would be to teach your Enterprise Scheduler about the Batch REST interface.  When it was time to run a Java Batch job, the scheduler could just use the REST interface to start it.  Later we’ll look at an Enterprise Scheduler that has done exactly this.

You could also have the scheduler run some program that drove a request into a server and the dispatched thing (a servlet, an EJB, etc.) would use the JobOperator interface to start the job. 

Another approach would be to have the scheduler run a script that executes the batchManager Command Line Interface.  It uses the REST interface under the covers to submit the job.  The CLI is capable of waiting for the job to complete too.  That means the script won’t end until the job ends which means the scheduler just runs something and when it is done, the job is done.

One more approach I’ll just mention briefly is the ability to simply have the scheduler start up a Liberty server where application initialization starts the job running.  You can find an example of this in the Tweet Analyzer sample in github under WASdev/sample.batch.tweetanalyzer.

As we noted under the discussion of the CLI, the tricky part of this isn’t always getting the job started but knowing when it is finished (for good or bad).  And if the job fails and you want to restart it, how do you automate that with an Enterprise Scheduler?