Implementing Streamed Batch Programs
The implementation of a streamed batch program may seem complex at first glance, however if the individual elements of the implementation are considered separately it can be broken down into more manageable tasks. This section should guide you through these tasks.
- Before you start
Before starting into the detail, there is one key note in relation to transaction management. - Modeling and Class structure
In other for the correct classes to be generated, along with the supporting meta-data for the batch launcher, a class must be defined in the UML model with one method of stereotype <<batch>> for each batch executable. - Chunker Entry-point
The process method described in the example above needs to complete a few steps in order to initialize and start the chunker. - Extra Processing
Extra processing is typically processing which logically belongs in the batch program, but does not fit in the context of any one chunk. As this is executed in a single transaction by the chunker the potential size of any processing needs to be considered carefully. - Setting the Batch Stream Entry Point
This method, called process in the example above, needs to set the instanceID, to a value that matches that set by the chunker, then call batchStreamHelper.runStream to start the stream processing. - Processing a Single Record ID
The core processing of the stream takes place in this method, implemented in processRecord. This method gets BatchProcessingID and batchProcessParameters as parameters and is expected to return a BatchProcessingResult instance containing the encoded results of its' processing. - Processing Skipped Cases
This method implemented by the stream in processSkippedCases is called once per chunk, passing in the list of skipped records, in a parameter of type BatchProcessingSkippedRecordList. - Encoding Batch Summary Information
The method implemented in getChunkResult is called at the end of each processed chunk to encode the results of the processing for this chunk. - Decoding Batch Summary Information
This processing needs to be implemented in the chunker, in the example above this is in a separate decodeProcessChunkResult method, which is reused from the Send Report processing. The meaning and ordering of the fields along with the encoding used needs to match the encoding processing implemented for the stream. - Sending a Batch Report
Report processing is implemented in the sendBatchReport method of the chunker. This method gets the InstanceID, BatchProcessDtls, ProcessedBatchProcessChunkDtlsList and UnprocessedBatchProcessChunkDtlsList as parameters. It is up to the developer as to what information is included in the report and how it is distributed (saved as a file, emailed, sent as a notification or task in the application, and so on). - Global Batch StreamConfiguration Options
There are a set of global configuration options which are set via EnvVars which effect the behavior of all streamed batch programs.