WebSphere Application Server

JSR-352 (Java Batch) Post #1: Batch Jobs in Java? YES! Modernizing Batch Applications with JSR-352

By David Follis posted Fri June 15, 2018 02:03 PM

  

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.

This series is also available as a podcast on iTunesGoogle PlayStitcher, or use the link to the RSS feed

The next post in the series is here.
------
When we think about batch applications, we usually think about ancient COBOL programs running in the middle of the night during the mysterious ‘batch window’.  But a batch application is really just a fixed sequence of process steps that occur in some specified order and start on some event.  It might be a bunch of COBOL running at 3 AM, but it might also be Java invoking a rules engine to process records in a file that showed up on an FTP site. 

A Batch process generally does a lot of things.  Maybe it processes a lot of records, doing the same basic thing for every record.  Maybe it works through a complex sequence of small steps, making decisions along the way about which step is next based on what it finds as it goes.

A batch application might be launched by an Enterprise Scheduler at a particular time or triggered by some event (a file arrives).  But a batch application might be triggered from some transactional event occurring.  Suppose a servlet is processing a fund transfer and there is a complex sequence of fraud detection steps that have to occur.  That processing could occur as a batch application kicked off by the servlet – which may or may not wait for it to finish.

If you want to write a batch application in Java, a good place to start is with JSR-352.  This open standard provides a framework for developing batch applications:  multiple steps, flow control between the steps based on results the current step, checkpoint/restart capability, concurrent execution of different steps, even concurrent execution of multiple copies of the same step, and more.

Of course, you could do all of that yourself in your own Java code.  But why?  JSR-352 provides a standard way to do it that is portable across various implementations and platforms.  And more importantly, you don’t have to maintain all that infrastructure code!  Just write the parts to read from (and write to) your data sources and then focus on the business logic.  The flow control and concurrency are all described in a standardized XML file.  And the whole thing can be bundled into a .war file just like your web applications (and maybe with that servlet that starts it). 

I’ve barely touched on all the cool things that are in JSR-352.  There’s a lot more, as well as some interesting tips and techniques that we might get into in further blog posts.  There’s lots of exciting and surprising things to be found in….batch!

-----------
Index of additional posts:

JSR-352 (Java Batch) Post #2: Basics of Batchlets
JSR-352 (Java Batch) Post #3: Stopping a Running Batchlet
JSR-352 (Java Batch) Post #4: Introducing the Step Context
JSR-352 (Java Batch) Post #5: Using StepContext UserData
JSR-352 (Java Batch) Post #6: Setting Step Exit Status Values
JSR-352 (Java Batch) Post #7: Basic Step Flow Control
JSR-352 (Java Batch) Post #8: Flow Control Using Step Exit Status
JSR-352 (Java Batch) Post #9: Using the Job Context Transient Data
JSR-352 (Java Batch) Post #10: Using the Job Properties from the JobContext
JSR-352 (Java Batch) Post #11: Setting the Job Exit Status
JSR-352 (Java Batch) Post #12: An Introduction to Listeners
JSR-352 (Java Batch) Post #13: Details of the Job Listener
JSR-352 (Java Batch) Post #14: Details of the Step Listener
JSR-352 (Java Batch) Post #15: Grouping Job Steps into Flows
JSR-352 (Java Batch) Post #16: Running Flows Concurrently with Splits: Splitting Up Is Easy To Do
JSR-352 (Java Batch) Post #17: Making Job Flow Decisions with a Decider (Part 1)
JSR-352 (Java Batch) Post #18: Making Job Flow Decisions with a Decider (Part 2)
JSR-352 (Java Batch) Post #19: Specifying Job Parameters
JSR-352 (Java Batch) Post #20: Setting and Using Job Properties
JSR-352 (Java Batch) Post #21:  JSL Substitution Syntax
JSR-352 (Java Batch) Post #22: Substitution Syntax Continued: Defaults
JSR-352 (Java Batch) Post #23: Substitution Syntax - More Realistic Samples
JSR-352 (Java Batch) Post #24:  One Chunk at a Time
JSR-352 (Java Batch) Post #25: Writing a Chunk-Step Reader
JSR-352 (Java Batch) Post #26: Processing Data with an ItemProcessor
JSR-352 (Java Batch) Post #27: Writing results with an ItemWriter
JSR-352 (Java Batch) Post #28: Ka-Chunk – What’s that? – Ka-Chunk – I think I heard something.. ​​
JSR-352 (Java Batch) Post #29: To Checkpoint Now, or Not To Checkpoint Now, and if Not Now, When?
JSR-352 (Java Batch) Post #30: Go (or Checkpoint) Your Own Way
JSR-352 (Java Batch) Post #31: Listen to the Rhythm of the Falling Rain (or the Chunk Processing…)
JSR-352 (Java Batch) Post #32: Five Little Monkeys, Jumping on the Bed…. Skipping in Java Batch
JSR-352 (Java Batch) Post #33: ‘Round and ‘Round – Retry Processing
JSR-352 (Java Batch) Post #34: Get Comfortable and Go Back In Your Mind with Retry-Rollback Processing
JSR-352 (Java Batch) Post #35: JSL Syntax for Retry with and without Rollback
JSR-352 (Java Batch) Post #36: A review of Chunk Step Listeners
JSR-352 (Java Batch) Post #37: Introduction to Partitions
JSR-352 (Java Batch) Post #38: Static Partition Control
JSR-352 (Java Batch) Post #39: Creating a Partition Plan Dynamically with a PartitionMapper
JSR-352 (Java Batch) Post #40: Coding a Skippable, Retryable, Restartable, Partitionable Reader
JSR-352 (Java Batch) Post #41: Analyze This! The Partition Step Collector and Analyzer
JSR-352 (Java Batch) Post #42: Partitions Too Fat? Get a Partition Reducer! (No, not really)
JSR-352 (Java Batch) Post #43: Restarting a Partitioned Step
JSR-352 (Java Batch) Post #44: Play it again, Sam! Restarting a failed job
JSR-352 (Java Batch) Post #45: Job Restart Processing – How it works..
JSR-352 (Java Batch) Post #46: Restarting a Chunk Step
JSR-352 (Java Batch) Post #47: Job Parameters when Restarting a Job
JSR-352 (Java Batch) Post #48: The Job Operator Interface
JSR-352 (Java Batch) Post #49: Try To Remember – The Job Repository
JSR-352 (Java Batch) Post #50: Moving on….to WebSphere Liberty
JSR-352 (Java Batch) Post #51: Job Repository Implementations – Part 1
JSR-352 (Java Batch) Post #52: Job Repository Implementations – Part 2
JSR-352 (Java Batch) Post #53: The REST Interface
JSR-352 (Java Batch) Post #54: JobOperator Functions via the REST interface
JSR-352 (Java Batch) Post #55: Purging Old Jobs
JSR-352 (Java Batch) Post #56: REST Interface page and pagesize Parameters


0 comments
157 views

Permalink