java batch
TRANSCRIPT
Java Batch(JSR-352)
M.Eray Koçak | Software Infrastructure
1950’s-60’s Batch Processing Era
The era came to an end, but need for batch processing continues to exist.
Evolution of Processing
Common Requirements
Common Requirements Logging Checkpointing Parallelization Transaction Management Operational Control
• Start• Stop• Restart
JSR-352
https://jcp.org/aboutJava/communityprocess/final/jsr352/index.html
Led by IBM The proposal intended to specify
• Batch job• Batch job step• Batch application• Batch executor• Batch job manager (Considered in a future revision of the
specification)• Final Release on 24 May, 2013
JSR-352[Final Release]
Describes Job Specification Language Java Programming Model Runtime environment of Batch Applications
Targets both Java SE and Java EE platforms. Requires Java 6 or higher. Works with dependency Injection(DI)
containers
Domain Language of Batch
Domain Language of Batch
Domain Language of Batch
Domain Language of Batch
Job Specification Language
Job Job Level Listeners Job Level Properties
Step
Each step may be either a chunk type step or batchlet type step
Chunk Periodically Checkpointed ItemBased
Batchlet Task-oriented
Chunk
Must have only one ItemReader and ItemWriter ItemProcessor is optional but only a single
processor element may be specified. Each Chunk is processed in a separate transaction ItemWriter is called once per chunk BatchRuntime writes checkpointinfo to
JobRepository
Chunk Exception Handling
Batchlet
Task-Oriented Batch Step Mutually exclusive with the chunk element. Closer analogy to CBBatchBase.prepare/finish
Step Listeners
Chunk Step Step Listener Item Read Listener Item Process Listener Item Write Listener Chunk Listener Skip Listener Retry Listener
Batclet Step Step Listener
Step Sequence
Transition Elements
Transition Elements next - directs execution flow to the next execution
element. fail - causes a job to end with FAILED batch status. end - causes a job to end with COMPLETED batch
status. stop - causes a job to end with STOPPED batch
status.
Transition Elements
Syntax
Step Partitioning
Step Partitioning
PartitionMapper partitionsOverride -> behaviour when Restart
PartitionReducer PartitionCollector PartitionAnalyzer
Batch and Exit Status
Batch Status : Runtime Status Value STARTING STARTED STOPPING STOPPED FAILED COMPLETED ABANDONED
Exit Status: User-defined Any String
Job XML Substituion
Job XML supports attribute value substitution Substitutions expressions may include a default
value using the "?:" operator Value is substituted with • Any resolvable Job Properties• Job Parameters• Partition Plan• System Properties
Job XML Substitution
Batch Programming Model
Described by interfaces, abstract classes, and field annotations.
Javax.batch package and subpackages
Batch Property
Must be used with the standard @Inject annotation (javax.inject.Inject).
Used to assign batch artifact property values from Job XML to the batch artifact itself
Batch Contexts
StepContext and JobContext are accessible via @Injection
Batch Runtime must ensure the correct context object is injected according to the job or step currently executing.
Job Metrics
Chunk-type step metrics are avaliable through the StepExecution runtime object. READ_COUNT, WRITE_COUNT, COMMIT_COUNT, ROLLBACK_COUNT, READ_SKIP_COUNT, PROCESS_SKIP_COUNT, FILTER_COUNT, WRITE_SKIP_COUNT
Job Runtime Identifiers
InstanceId ExecutionId StepExecutionId
JobOperator
Provides a set of operations to start, stop, restart, and inspect jobs.
Application Packaging Model
No unique packaging is required Jar War EJB Jar
Batch Artifact Loading
Implementation-specific loader Archive loader
META-INF Thread Context Class Loader
Job XML Loading
implementation-specific loader archive loader
IBM Extensions
Built on Liberty Profile as the Java Runtime Server Liberty Profile 8.5.5.6 and above
Extensions: Rest interface to JobOperator Command line client for job submission Multi-JVM support: Jobs or partitions can be
executed in a distributed topology
IBM JobRepository Implementation
In-memory File-Based Derby Relational database product
REST Interface to JobOperator
Provides a way to integrate with Schedulers
REST Submit
GET Job Instance Information
REST GET Job Execution Information
REST GET Step Execution Information
Multi-JVM Topology
Message Selectors
Use to pick up messages by executor servers.
Liberty Profile Server.xml
Questions