SlideShare a Scribd company logo
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.1
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.2
Batch Applications for the
Java Platform
Arun Gupta
Java EE & GlassFish Guy
arun.p.gupta@oracle.com
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3
The following is intended to outline our general product direction. It is intended
for information purposes only, and may not be incorporated into any contract.
It is not a commitment to deliver any material, code, or functionality, and should
not be relied upon in making purchasing decisions. The development, release,
and timing of any features or functionality described for Oracle’s products
remains at the sole discretion of Oracle.
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4
Batch Applications for the Java Platform
§ Standardizes batch processing for Java
–  Non-interactive, bulk-oriented, long-running
–  Data or computationally intensive
–  Sequentially or in parallel
–  Ad-hoc, scheduled or on-demand execution
§ Led by IBM
§ Spring Batch, WebSphere Compute Grid (WCG), z/OS Batch
§ Part of Java EE 7, can be used in Java SE
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5
Batch Domain Language
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6
Batch Domain Language
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7
Batch Domain Language
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8
Chunked Processing
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9
Chunked Processing: Reader, Processor, Writer
public interface ItemReader<T> {
public void open(Externalizable checkpoint);
public T readItem();
public Externalizable checkpointInfo();
public void close();
}
public interface ItemProcessor<T, R> {
public R processItem(T item);
}
public interface ItemWriter<T> {
public void open(Externalizable checkpoint);
public void writeItems(List<T> items);
public Externalizable checkpointInfo();
public void close();
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10
//For a job
<step id=”sendStatements”>
<chunk reader=”accountReader”
processor=”accountProcessor”
writer=”emailWriter”
item-count=”10” />
</step>
Batch Applications for the Java Platform
Step Example using Job Specification Language (JSL)
@Named(“accountReader")
...implements ItemReader... {
public Account readItem() {
// read account using JPA
@Named(“accountProcessor")
...implements ItemProcessor... {
public Statement processItems(Account account) {
// read Account, return Statement
@Named(“emailWriter")
...implements ItemWriter... {
public void writeItems(List<Statements> statements) {
// use JavaMail to send email
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11
Checkpointing
§ For data intensive tasks, long periods of time
–  Checkpoint/restart is a common design requirement
§ Basically saves Reader, Writer positions
–  Naturally fits into Chunk oriented steps
–  reader.checkpointInfo() and writer.checkpointInfo() are
called
–  The resulting Externalizable data is persisted
–  When the Chunk restarts, the reader and writer are initialized with the
respective Externalizable data
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12
Chunked Processing: Checkpoint
public interface ItemReader<T> {
public void open(Externalizable checkpoint);
public T readItem();
public Externalizable checkpointInfo();
public void close();
}
public interface ItemProcessor<T, R> {
public R processItem(T item);
}
public interface ItemWriter<T> {
public void open(Externalizable checkpoint);
public void writeItems(List<T> items);
public Externalizable checkpointInfo();
public void close();
}
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13
Handling Exceptions
<job id=...>
...
<chunk skip-limit=”5” retry-limit=”5”>
<skippable-exception-classes>
<include class="java.lang.Exception"/>
<exclude class="java.io.FileNotFoundException"/>
</skippable-exception-classes>
<retryable-exception-classes>
...
</retryable-exception-classes>
<no-rollback-exception-classes>
...
</no-rollback-exception-classes>
</chunk>
...
</job>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14
Partitioned Step
§ A batch step may run as a partitioned step
–  A partitioned step runs as multiple instances of the same step definition
across multiple threads, one partition per thread
<step id="step1" >
<chunk ...>
<partition>
<plan partitions=“10" threads="2"/>
<reducer .../>
</partition>
</chunk>
</step>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15
Partitioning – Advanced Scenarios
§ Partition Mapper
–  Dynamically decide number of partitions (partition plan)
§  Partition Reducer
–  Demarcate logical unit of work around partition processing
§  Partition Collector
–  Sends interim results from individual partition to step's partition
analyzer
§  Partition Analyzer
–  Collection point of interim results, single point of control and analysis
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16
Flow and Split
§ Flow defines a set of steps to be executed as a unit
<flow id=”flow-1" next=“{flow, step, decision}-id” >
<step id=“flow_1_step_1”>
</step>
<step id=“flow_1_step_2”>
</step>
</flow>
§ Split defines a set of flows to be executed in parallel
<split …>
<flow …./> <!– each flow runs on a separate thread -->
<flow …./>
</split>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17
Batchlet
§ Task oriented unit of work
§  Not item-oriented
§ Doesn't support resume
§ Simple Batchlet interface – process(), stop()!
§ In Job XML:
<batchlet ref=”{name}”/>
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18
Programming Model – Advanced Scenarios
§ CheckpointAlgorithm
§ Decider
§ Listeners – Job, Step, Chunk Listeners …
§ @BatchProperty

String fname = “/tmp/default.txt”!
§ @BatchContext JobContext jctxt;!
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19
Batch Runtime Specification
§ JobOperator interface – for programmatic lifecycle control of jobs
§ Step level Metrics through the StepExecution object
§ Batch Artifact loading through CDI
§ Job XML loading through META-INF/batch-jobs/myJob.xml
§ Packaging – jar, war, ejb-jar
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20
Example: Programmatic Invocation of Jobs
In a Servlet/EJB:
import javax.batch.runtime.BatchRuntime;
...
JobOperator jo = BatchRuntime.getJobOperator();
jo.start("myJob", new Properties());
...
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21
Where to Find Out More
§ Read the final spec and API docs at http://java.net/projects/jbatch/
§ Join public@jbatch.java.net and send questions and comments
§ RI integrated in GlassFish 4.0
–  http://glassfish.java.net/
–  http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22
Graphic Section Divider
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23

More Related Content

PDF
Java API for WebSocket 1.0: Java EE 7 and GlassFish
PDF
CON5898 What Servlet 4.0 Means To You
PDF
JavaOne 2014 BOF4241 What's Next for JSF?
PDF
What's next for Java API for WebSocket (JSR 356)
PPTX
Servlet 4.0 at GeekOut 2015
PPTX
HTTP/2 comes to Java. What Servlet 4.0 means to you. DevNexus 2015
PPT
What's New in WebLogic 12.1.3 and Beyond
 
PDF
WebSockets in Enterprise Applications
Java API for WebSocket 1.0: Java EE 7 and GlassFish
CON5898 What Servlet 4.0 Means To You
JavaOne 2014 BOF4241 What's Next for JSF?
What's next for Java API for WebSocket (JSR 356)
Servlet 4.0 at GeekOut 2015
HTTP/2 comes to Java. What Servlet 4.0 means to you. DevNexus 2015
What's New in WebLogic 12.1.3 and Beyond
 
WebSockets in Enterprise Applications

What's hot (19)

PPT
Reactive Java EE - Let Me Count the Ways!
PPTX
Ed presents JSF 2.2 and WebSocket to Gameduell.
PDF
Java EE 7 from an HTML5 Perspective, JavaLand 2015
PDF
Java EE 7 for WebLogic 12c Developers
PDF
Burns jsf-confess-2015
PDF
Java EE Revisits GoF Design Patterns
PDF
WebSocket in Enterprise Applications 2015
PDF
MVC 1.0 / JSR 371
PPTX
JavaFX and JEE 7
PPT
Have You Seen Java EE Lately?
PPTX
Oracle WebLogic Server 12.2.1 Do More with Less
PDF
EJB and CDI - Alignment and Strategy
PDF
JSF 2.2 Input Output JavaLand 2015
PPTX
Move from J2EE to Java EE
PDF
JavaFX Enterprise
PPTX
Seven Points for Applying Java EE 7
PPTX
[RakutenTechConf2013] [E-3] Financial Web System with Java EE 6
PPTX
Oracle WebLogic Server 12c: Seamless Oracle Database Integration (with NEC, O...
PPTX
JSR 236 Concurrency Utils for EE presentation for JavaOne 2013 (CON7948)
Reactive Java EE - Let Me Count the Ways!
Ed presents JSF 2.2 and WebSocket to Gameduell.
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 for WebLogic 12c Developers
Burns jsf-confess-2015
Java EE Revisits GoF Design Patterns
WebSocket in Enterprise Applications 2015
MVC 1.0 / JSR 371
JavaFX and JEE 7
Have You Seen Java EE Lately?
Oracle WebLogic Server 12.2.1 Do More with Less
EJB and CDI - Alignment and Strategy
JSF 2.2 Input Output JavaLand 2015
Move from J2EE to Java EE
JavaFX Enterprise
Seven Points for Applying Java EE 7
[RakutenTechConf2013] [E-3] Financial Web System with Java EE 6
Oracle WebLogic Server 12c: Seamless Oracle Database Integration (with NEC, O...
JSR 236 Concurrency Utils for EE presentation for JavaOne 2013 (CON7948)
Ad

Similar to Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish (20)

PDF
Batch Applications for the Java Platform
PDF
Design & Develop Batch Applications in Java/JEE
PDF
Java one 2015 [con3339]
PDF
Three Key Concepts for Understanding JSR-352: Batch Programming for the Java ...
PPTX
PDF
Spring batch overivew
PPTX
Spring batch
PDF
Three key concepts for java batch
PDF
Java EE 7 Batch processing in the Real World
PPTX
Batching and Java EE (jdk.io)
PPTX
Spring batch for large enterprises operations
PPTX
Spring batch
PPT
Was l iberty for java batch and jsr352
PPTX
Spring batch
PPT
Spring Batch Introduction
PDF
Gain Proficiency in Batch Processing with Spring Batch
DOCX
springn batch tutorial
 
PPTX
Spring batch introduction
PDF
Atlanta JUG - Integrating Spring Batch and Spring Integration
PPT
Spring Batch 2.0
Batch Applications for the Java Platform
Design & Develop Batch Applications in Java/JEE
Java one 2015 [con3339]
Three Key Concepts for Understanding JSR-352: Batch Programming for the Java ...
Spring batch overivew
Spring batch
Three key concepts for java batch
Java EE 7 Batch processing in the Real World
Batching and Java EE (jdk.io)
Spring batch for large enterprises operations
Spring batch
Was l iberty for java batch and jsr352
Spring batch
Spring Batch Introduction
Gain Proficiency in Batch Processing with Spring Batch
springn batch tutorial
 
Spring batch introduction
Atlanta JUG - Integrating Spring Batch and Spring Integration
Spring Batch 2.0
Ad

More from Arun Gupta (20)

PDF
5 Skills To Force Multiply Technical Talents.pdf
PPTX
Machine Learning using Kubernetes - AI Conclave 2019
PDF
Machine Learning using Kubeflow and Kubernetes
PPTX
Secure and Fast microVM for Serverless Computing using Firecracker
PPTX
Building Java in the Open - j.Day at OSCON 2019
PPTX
Why Amazon Cares about Open Source
PDF
Machine learning using Kubernetes
PDF
Building Cloud Native Applications
PDF
Chaos Engineering with Kubernetes
PDF
How to be a mentor to bring more girls to STEAM
PDF
Java in a World of Containers - DockerCon 2018
PPTX
The Serverless Tidal Wave - SwampUP 2018 Keynote
PDF
Introduction to Amazon EKS - KubeCon 2018
PDF
Mastering Kubernetes on AWS - Tel Aviv Summit
PDF
Top 10 Technology Trends Changing Developer's Landscape
PDF
Container Landscape in 2017
PDF
Java EE and NoSQL using JBoss EAP 7 and OpenShift
PDF
Docker, Kubernetes, and Mesos recipes for Java developers
PDF
Thanks Managers!
PDF
Migrate your traditional VM-based Clusters to Containers
5 Skills To Force Multiply Technical Talents.pdf
Machine Learning using Kubernetes - AI Conclave 2019
Machine Learning using Kubeflow and Kubernetes
Secure and Fast microVM for Serverless Computing using Firecracker
Building Java in the Open - j.Day at OSCON 2019
Why Amazon Cares about Open Source
Machine learning using Kubernetes
Building Cloud Native Applications
Chaos Engineering with Kubernetes
How to be a mentor to bring more girls to STEAM
Java in a World of Containers - DockerCon 2018
The Serverless Tidal Wave - SwampUP 2018 Keynote
Introduction to Amazon EKS - KubeCon 2018
Mastering Kubernetes on AWS - Tel Aviv Summit
Top 10 Technology Trends Changing Developer's Landscape
Container Landscape in 2017
Java EE and NoSQL using JBoss EAP 7 and OpenShift
Docker, Kubernetes, and Mesos recipes for Java developers
Thanks Managers!
Migrate your traditional VM-based Clusters to Containers

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
 
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation theory and applications.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
 
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
cuic standard and advanced reporting.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
The AUB Centre for AI in Media Proposal.docx
 
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
A Presentation on Artificial Intelligence
Encapsulation theory and applications.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
MYSQL Presentation for SQL database connectivity
Per capita expenditure prediction using model stacking based on satellite ima...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Reach Out and Touch Someone: Haptics and Empathic Computing
CIFDAQ's Market Insight: SEC Turns Pro Crypto
 
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Understanding_Digital_Forensics_Presentation.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Big Data Technologies - Introduction.pptx
Empathic Computing: Creating Shared Understanding
Review of recent advances in non-invasive hemoglobin estimation
cuic standard and advanced reporting.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...

Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish

  • 1. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.1
  • 2. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.2 Batch Applications for the Java Platform Arun Gupta Java EE & GlassFish Guy arun.p.gupta@oracle.com
  • 3. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3 The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
  • 4. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4 Batch Applications for the Java Platform § Standardizes batch processing for Java –  Non-interactive, bulk-oriented, long-running –  Data or computationally intensive –  Sequentially or in parallel –  Ad-hoc, scheduled or on-demand execution § Led by IBM § Spring Batch, WebSphere Compute Grid (WCG), z/OS Batch § Part of Java EE 7, can be used in Java SE
  • 5. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5 Batch Domain Language
  • 6. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6 Batch Domain Language
  • 7. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7 Batch Domain Language
  • 8. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8 Chunked Processing
  • 9. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9 Chunked Processing: Reader, Processor, Writer public interface ItemReader<T> { public void open(Externalizable checkpoint); public T readItem(); public Externalizable checkpointInfo(); public void close(); } public interface ItemProcessor<T, R> { public R processItem(T item); } public interface ItemWriter<T> { public void open(Externalizable checkpoint); public void writeItems(List<T> items); public Externalizable checkpointInfo(); public void close(); }
  • 10. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10 //For a job <step id=”sendStatements”> <chunk reader=”accountReader” processor=”accountProcessor” writer=”emailWriter” item-count=”10” /> </step> Batch Applications for the Java Platform Step Example using Job Specification Language (JSL) @Named(“accountReader") ...implements ItemReader... { public Account readItem() { // read account using JPA @Named(“accountProcessor") ...implements ItemProcessor... { public Statement processItems(Account account) { // read Account, return Statement @Named(“emailWriter") ...implements ItemWriter... { public void writeItems(List<Statements> statements) { // use JavaMail to send email
  • 11. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11 Checkpointing § For data intensive tasks, long periods of time –  Checkpoint/restart is a common design requirement § Basically saves Reader, Writer positions –  Naturally fits into Chunk oriented steps –  reader.checkpointInfo() and writer.checkpointInfo() are called –  The resulting Externalizable data is persisted –  When the Chunk restarts, the reader and writer are initialized with the respective Externalizable data
  • 12. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12 Chunked Processing: Checkpoint public interface ItemReader<T> { public void open(Externalizable checkpoint); public T readItem(); public Externalizable checkpointInfo(); public void close(); } public interface ItemProcessor<T, R> { public R processItem(T item); } public interface ItemWriter<T> { public void open(Externalizable checkpoint); public void writeItems(List<T> items); public Externalizable checkpointInfo(); public void close(); }
  • 13. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13 Handling Exceptions <job id=...> ... <chunk skip-limit=”5” retry-limit=”5”> <skippable-exception-classes> <include class="java.lang.Exception"/> <exclude class="java.io.FileNotFoundException"/> </skippable-exception-classes> <retryable-exception-classes> ... </retryable-exception-classes> <no-rollback-exception-classes> ... </no-rollback-exception-classes> </chunk> ... </job>
  • 14. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14 Partitioned Step § A batch step may run as a partitioned step –  A partitioned step runs as multiple instances of the same step definition across multiple threads, one partition per thread <step id="step1" > <chunk ...> <partition> <plan partitions=“10" threads="2"/> <reducer .../> </partition> </chunk> </step>
  • 15. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15 Partitioning – Advanced Scenarios § Partition Mapper –  Dynamically decide number of partitions (partition plan) §  Partition Reducer –  Demarcate logical unit of work around partition processing §  Partition Collector –  Sends interim results from individual partition to step's partition analyzer §  Partition Analyzer –  Collection point of interim results, single point of control and analysis
  • 16. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16 Flow and Split § Flow defines a set of steps to be executed as a unit <flow id=”flow-1" next=“{flow, step, decision}-id” > <step id=“flow_1_step_1”> </step> <step id=“flow_1_step_2”> </step> </flow> § Split defines a set of flows to be executed in parallel <split …> <flow …./> <!– each flow runs on a separate thread --> <flow …./> </split>
  • 17. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17 Batchlet § Task oriented unit of work §  Not item-oriented § Doesn't support resume § Simple Batchlet interface – process(), stop()! § In Job XML: <batchlet ref=”{name}”/>
  • 18. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18 Programming Model – Advanced Scenarios § CheckpointAlgorithm § Decider § Listeners – Job, Step, Chunk Listeners … § @BatchProperty
 String fname = “/tmp/default.txt”! § @BatchContext JobContext jctxt;!
  • 19. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19 Batch Runtime Specification § JobOperator interface – for programmatic lifecycle control of jobs § Step level Metrics through the StepExecution object § Batch Artifact loading through CDI § Job XML loading through META-INF/batch-jobs/myJob.xml § Packaging – jar, war, ejb-jar
  • 20. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20 Example: Programmatic Invocation of Jobs In a Servlet/EJB: import javax.batch.runtime.BatchRuntime; ... JobOperator jo = BatchRuntime.getJobOperator(); jo.start("myJob", new Properties()); ...
  • 21. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21 Where to Find Out More § Read the final spec and API docs at http://java.net/projects/jbatch/ § Join public@jbatch.java.net and send questions and comments § RI integrated in GlassFish 4.0 –  http://glassfish.java.net/ –  http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/
  • 22. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22 Graphic Section Divider
  • 23. Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23