WebSphere Application Server

JSR-352 (Java Batch) Post #74: Split/Flow Events

By David Follis posted Wed January 22, 2020 07:36 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
-----

The last in our series about batch events (finally!).  This time we’re going to look at the event messages published around the processing of a split/flow. 

We talked about those quite a while ago, so let’s review.  By wrapping <flow> elements around one or more <step> elements in a job we can define a flow.  The flow has a name (just like a step or any other element in the job). 

If we have one or more flows together, we can wrap <split> elements around the flows and create a split/flow (of course!).  When processing for the job proceeds to the split element (which also has its own identifying name) processing on the thread of the job encountering the split stops and processing for each flow within the split is spun off to other threads. 

When all the steps within a flow are completed, meaning a step with no transition to another step was encountered, then the flow is done.  When all the flows are done, the split is complete. 

What batch event messages get produced for all of this?  Well, nothing happens from the split itself.  The thread encountering the split just stops until all the flows are done.  However, as each flow begins a message is published to the split started topic.  You’ll get one started message for each flow within the split.  As with partitions, these might not all happen at once depending on availability of threads to run the flows and processor resources to run the threads.

Once the flow is running, it produces step-related events just like any other step outside a flow.  Remember that a flow can contain regular and partitioned steps.  And, brace yourself, a flow can contain another split that contains more flows.  So this can get pretty complicated, if you let it.

Once all the steps in a flow are complete, the flow ends, and a message is published to the split ended topic to let you know that flow is done. 

Without knowing the JSL you have no way of knowing how many flows are within a split so you can’t really show the status of all the flows for sure.  Just the ones you’ve seen started and ended. 

That’s it for batch event messages.  Next time we’re on to a whole new topic…
0 comments
8 views

Permalink