Batching and Java EE (jdk.io)

Ryan Cuprak
Ryan CuprakCPG & Retail, Formulation R&D Development Senior Manager
BATCHING AND
JAVA EE
Ryan Cuprak
What is Batch Processing?
Batch jobs are typically:
• Bulk-oriented
• Non-interactive
• Potentially compute intensive
• May require parallel execution
• Maybe invoked, ad hoc, scheduled, on-demand etc.
Batching Examples
• Monthly reports/statements
• Daily data cleanup
• One-time data migrations
• Data synchronization
• Data analysis
• Portfolio rebalancing
Introducing Java EE Batching
• Introduced in Java EE 7
• JSR 352 - https://jcp.org/en/jsr/detail?id=352
• Reference implementation:
https://github.com/WASdev/standards.jsr352.jbatch
• Batch Framework:
• Batch container for execution of jobs
• XML Job Specification Language
• Batch annotations and interfaces
• Supporting classes and interfaces for interacting with the
container
• Depends on CDI
Java EE Batching Overview
JobOperator Job Step
JobRepository
ItemReader
ItemProcessor
ItemWriter
1 *
1
1
1 1
1
1
Java EE Batching Overview
JobInstance
Job
JobExecution
*
*
EndOfDayJob
EndOfDayJob for 9/1/2016
First attempt at EndOfDay
job for 9/1/2016
Java EE Batching Features
• Fault-tolerant – checkpoints and job persistence
• Transactions - chunks execute within a JTA transaction
• Listeners – notification of job status/completion/etc.
• Resource management – limits concurrent jobs
• Starting/stopping/restarting – job control API
Java EE Batching Deployment
WAR EAR JAR
Deploy batch jobs in:
Manage jobs – split application into modules
Server B
app.war
End of Day
Job
Cleanup Job
Server C
app2.war
Analytics Job
Server A
frontend.war
Batchlet
Exit Codes
Code Description
STARTING Job has been submitted to runtime.
STARTED Batch job has started executing.
STOPPING Job termination has been requested.
STOPPED Job has been stopped.
FAILED Job has thrown an error or failured triggered by
<failure>
COMPLETED Job has completed normally.
ABANDONDED Job cannot be restarted
Basic Layout
CDI Configuration
Job Configuration
Batchlet
Job Configuration
META-INF/batch-jobs/<job-name>.xml
Batch Runtime
Batchlet with Termination
Jobs should implement and
terminate when requested!
Batching & Resources
Concurrent Resources
IDs and Names
instanceId
• ID represents an instance of a job.
• Created when JobOperator start method invoked.
executionId
• ID that represents the next attempt to run a particular job
instance.
• Created when a job is started/restarted.
• Only one executionId for a job can be started at a time
stepExecutionId
• ID for an attempt to execute a particular step in a job
jobName
• name of the job from XML (actually id) <job id=“”>
jobXMLName
• name of the config file in META-INF/batch-jobs
JobInstance vs. JobExecution
JobInstance
JobExecution
1
*
• BatchStatus
• createTime
• endTime
• executionID
• exitStatus
• jobName
• jobParameters,
lastUpdateTime
• startTime
• instanceId
• jobName
Managing Jobs
• JobOperator – interface for operating on batch jobs.
• BatchRuntime.getJobOperator()
• JobOperator:
• Provides information on current and completed jobs
• Used to start/stop/restart/abandon jobs
• Security is implementation dependent
• JobOperator interacts with JobRepository
• JobRepository
• Implementation out-side scope of JSR
• No API for deleting old jobs
• Reference implementation provides no API for cleanup!
JobOperator Methods
Type Method
void Abandon(long executionId)
JobExecution getJobExecution(long executionId)
List<JobExecution> getJobExecutions(JobInstance instance)
JobInstance getJobInstance(long executionId)
int getJobInstanceCount(String jobName)
List<JobInstance> getJobInstances(String jobName,int start, in count)
Set<String> getJobNames()
Properties getParameters(long executionId)
List<Long> getRunningExecutions(String jobName)
List<StepExecution> getStepExecutions(long jobExecutionId)
long Restart(long executionId, Properties restartParams)
long start(String jobXMLName, Properties jobParams)
void Stop(long executionId)
Listing Batch Jobs
Chunking
• Chunking is primary pattern for batch processing in JSR-
352.
• Encapsulates the ETL pattern:
• Pieces: Reader/Processor/Writer
• Reader/Processor invoked until an entire chuck of data is
processed.
• Output is written atomically
• Implementation:
• Interfaces: ItemReader/ItemWriter/ItemProcessor
• Classes: AbstractReader/AbstractWriter/AbstractProcessor
Reader Processor Writer
Chunking
Chunk Configuration
Parameter Description
checkpoint-policy Possible values: item or custom
item-count Number of items to be processed per
chunk. Default is 10.
time-limit Time in seconds before taking a
checkpoint. Default is 0 (means after
each chunk)
skip-limit Number of exceptions a step will skip
if there are configured skippable
exceptions.
retry-limit Number of times a step will be retried
if it has throw a skippable exception.
Skippable Exceptions
Chunking
Step ItemReader ItemProcessor ItemWriter
read()
item
process(item)
item
read()
item
process(item)
item
write(items)
execute()
ExitStatus
Chunking: ItemReader
Chunking: ItemProcessor
Chunking: ItemWriter
Demo
Runtime Parameters
Set Property
Retrieve Property
Pre-Defined Properties
Set Property
Property Injected
Step Exceptions
• Parallel running instances (partition) complete before the
job completes.
• Batch status transitions to FAILED
Job Listener Configuration
Listener
Config
Job Listener Implementation
Step Listener Configuration
Listener
Config
Step Listener Implementation
Partition Configuration
Partition Implementation
Decision Configuration
Decision
What next?
Decision Implementation
Dependency Injection!
Split
updateExisting processNewStorms
Flow & Splits JCL
• <flow> element is used to implement process workflows.
• <split> element is used to run jobs in parallel
retrieveTracking
processDecider
stormReader
stormProcessor
stormWriter
updateExisting
Storms
Flows & Splits
Checkpoint Algorithm Configuration
Checkpoint Algorithm Implementation
Hadoop Overview
• Massively scalable storage and batch data processing
system
• Written in Java
• Huge ecosystem
• Meant for massive data processing jobs
• Horizontally scalable
• Uses MapReduce programming model
• Handles processing of petabytes of data
• Started at Yahoo! In 2005.
Hadoop
MapReduce
(Distributed Computation)
HDFS
(Distributed Storage)
YARN
Framework
Common
Utilities
Hadoop
Typically Hadoop is used when:
• Analysis is performed on unstructured datasets
• Data is stored across multiple servers (HDFS)
• Non-Java processes are fed data and managed
Ex. https://svi.nl/HuygensSoftware
Spring vs. Java EE Batching
• Spring Batch 3.0 implements JSR-352!
• Batch artifacts developed against JSR-352 won’t work
within a traditional Spring Batch Job
• Same two processing models as Spring Batch:
• Item – aka chunking
• Task - aka Batchlet
Terminology Comparison
JSR-352 Spring Batch
Job Job
Step Step
Chunk Chunk
Item Item
ItemReader ItemReader/ItemStream
ItemProcessor ItemProcessor
ItemWriter ItemWriter/ItemStream
JobInstance JobInstance
JobExecution JobExecution
StepExecution StepExecution
JobListener JobExecutionListener
StepListener StepExecutionListener
Scaling Batch Jobs
• Traditional Spring Batch Scaling:
• Split – running multiple steps in parallel
• Multiple threads – executing a single step via multiple threads
• Partitioning – dividing data up for parallel processing
• Remote Chunking – executing the processor logic remotely
• JSR-352 Job Scaling
• Split – running multiple steps in parallel
• Partitioning – dividing data up – implementation slightly different.
JSR-352/Spring/Hadoop
Hadoop
• Massively parallel / large jobs
• Processing petabytes of data (BIG DATA)
JSR-352/Spring
• Traditional batch processing jobs
• Structured data/business processes
JSR-352 vs. Spring
• Java EE versus Spring containers
• Spring has better job scaling capabilities
JSR-352 Implementations
• JBeret
• http://tinyurl.com/z4qx3wo
• WebSphere/WebLogic/Payara
• jbatch (reference)
• http://tinyurl.com/jk6vcb8
• WildFly/JBoss
• SpringBatch
• http://tinyurl.com/mt8v3k7
Best Practices
• Package/deploy batch jobs separately
• Implement logic to cleanup old jobs
• Implement logic for auto-restart
• Test restart and checkpoint logic
• Configure database to store jobs
• Configure thread pool for batch jobs
• Only invoke batch jobs from logic that is secured (@Role
etc.)
Resources
• JSR-352
https://jcp.org/en/jsr/detail?id=352
• Java EE Support
http://javaee.support/contributors/
• Spring Batch
http://docs.spring.io/spring-batch/reference/html/spring-batch-
intro.html
• Spring JSR-352 Support
http://docs.spring.io/spring-batch/reference/html/jsr-352.html
Resources
• Java EE 7 Batch Processing and World of Warcraft
http://tinyurl.com/gp8yls8
• Three Key Concepts for Understanding JSR-352
http://tinyurl.com/oxe2dhu
• Java EE Tutorial
https://docs.oracle.com/javaee/7/tutorial/batch-
processing.htm
Q&A
Email: rcuprak@gmail.com
Twitter: @ctjava
1 of 57

Recommended

Vert.x for Microservices Architecture by
Vert.x for Microservices ArchitectureVert.x for Microservices Architecture
Vert.x for Microservices ArchitectureIdan Fridman
3.2K views49 slides
Kafka replication apachecon_2013 by
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013Jun Rao
21.3K views31 slides
Reactive programming by
Reactive programmingReactive programming
Reactive programmingSUDIP GHOSH
215 views41 slides
Spring Batch 2.0 by
Spring Batch 2.0Spring Batch 2.0
Spring Batch 2.0Guido Schmutz
8.2K views35 slides
REST APIs with Spring by
REST APIs with SpringREST APIs with Spring
REST APIs with SpringJoshua Long
25.6K views103 slides
Reactive Programming In Java Using: Project Reactor by
Reactive Programming In Java Using: Project ReactorReactive Programming In Java Using: Project Reactor
Reactive Programming In Java Using: Project ReactorKnoldus Inc.
607 views24 slides

More Related Content

What's hot

Networking in Java with NIO and Netty by
Networking in Java with NIO and NettyNetworking in Java with NIO and Netty
Networking in Java with NIO and NettyConstantine Slisenka
11.7K views60 slides
Spring Boot by
Spring BootSpring Boot
Spring BootHongSeong Jeon
3.9K views41 slides
Xke spring boot by
Xke spring bootXke spring boot
Xke spring bootsourabh aggarwal
1.3K views20 slides
Spring Boot in Action by
Spring Boot in Action Spring Boot in Action
Spring Boot in Action Alex Movila
3K views55 slides
Removing performance bottlenecks with Kafka Monitoring and topic configuration by
Removing performance bottlenecks with Kafka Monitoring and topic configurationRemoving performance bottlenecks with Kafka Monitoring and topic configuration
Removing performance bottlenecks with Kafka Monitoring and topic configurationKnoldus Inc.
1.3K views15 slides
Java EE 7 Batch processing in the Real World by
Java EE 7 Batch processing in the Real WorldJava EE 7 Batch processing in the Real World
Java EE 7 Batch processing in the Real WorldRoberto Cortez
23.5K views47 slides

What's hot(20)

Spring Boot in Action by Alex Movila
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
Alex Movila3K views
Removing performance bottlenecks with Kafka Monitoring and topic configuration by Knoldus Inc.
Removing performance bottlenecks with Kafka Monitoring and topic configurationRemoving performance bottlenecks with Kafka Monitoring and topic configuration
Removing performance bottlenecks with Kafka Monitoring and topic configuration
Knoldus Inc.1.3K views
Java EE 7 Batch processing in the Real World by Roberto Cortez
Java EE 7 Batch processing in the Real WorldJava EE 7 Batch processing in the Real World
Java EE 7 Batch processing in the Real World
Roberto Cortez23.5K views
Towards Flink 2.0: Unified Batch & Stream Processing - Aljoscha Krettek, Verv... by Flink Forward
Towards Flink 2.0: Unified Batch & Stream Processing - Aljoscha Krettek, Verv...Towards Flink 2.0: Unified Batch & Stream Processing - Aljoscha Krettek, Verv...
Towards Flink 2.0: Unified Batch & Stream Processing - Aljoscha Krettek, Verv...
Flink Forward1.9K views
L'API Collector dans tous ses états by José Paumard
L'API Collector dans tous ses étatsL'API Collector dans tous ses états
L'API Collector dans tous ses états
José Paumard1.2K views
Deep Dive Java 17 Devoxx UK by José Paumard
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
José Paumard984 views
Hibernate Presentation by guest11106b
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
guest11106b20.4K views
CDC Stream Processing with Apache Flink by Timo Walther
CDC Stream Processing with Apache FlinkCDC Stream Processing with Apache Flink
CDC Stream Processing with Apache Flink
Timo Walther368 views
Apache Kafka Architecture & Fundamentals Explained by confluent
Apache Kafka Architecture & Fundamentals ExplainedApache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals Explained
confluent27.7K views
Spring Framework - Core by Dzmitry Naskou
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
Dzmitry Naskou34.8K views
Understanding Reactive Programming by Andres Almiray
Understanding Reactive ProgrammingUnderstanding Reactive Programming
Understanding Reactive Programming
Andres Almiray1.2K views
Real Time UI with Apache Kafka Streaming Analytics of Fast Data and Server Push by Lucas Jellema
Real Time UI with Apache Kafka Streaming Analytics of Fast Data and Server PushReal Time UI with Apache Kafka Streaming Analytics of Fast Data and Server Push
Real Time UI with Apache Kafka Streaming Analytics of Fast Data and Server Push
Lucas Jellema3.4K views
Advanced task management with Celery by Mahendra M
Advanced task management with CeleryAdvanced task management with Celery
Advanced task management with Celery
Mahendra M63.2K views
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor by VMware Tanzu
Reactive Card Magic: Understanding Spring WebFlux and Project ReactorReactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
VMware Tanzu3.7K views

Viewers also liked

Top 50 java ee 7 best practices [con5669] by
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Ryan Cuprak
9.3K views78 slides
Java EE 8 Update by
Java EE 8 UpdateJava EE 8 Update
Java EE 8 UpdateRyan Cuprak
9.6K views63 slides
Jms deep dive [con4864] by
Jms deep dive [con4864]Jms deep dive [con4864]
Jms deep dive [con4864]Ryan Cuprak
2.2K views66 slides
Containerless in the Cloud with AWS Lambda by
Containerless in the Cloud with AWS LambdaContainerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS LambdaRyan Cuprak
1.4K views69 slides
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014) by
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Ryan Cuprak
15.8K views132 slides
Faster Java EE Builds with Gradle by
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
1.9K views71 slides

Viewers also liked(20)

Top 50 java ee 7 best practices [con5669] by Ryan Cuprak
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]
Ryan Cuprak9.3K views
Java EE 8 Update by Ryan Cuprak
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
Ryan Cuprak9.6K views
Jms deep dive [con4864] by Ryan Cuprak
Jms deep dive [con4864]Jms deep dive [con4864]
Jms deep dive [con4864]
Ryan Cuprak2.2K views
Containerless in the Cloud with AWS Lambda by Ryan Cuprak
Containerless in the Cloud with AWS LambdaContainerless in the Cloud with AWS Lambda
Containerless in the Cloud with AWS Lambda
Ryan Cuprak1.4K views
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014) by Ryan Cuprak
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Ryan Cuprak15.8K views
Faster Java EE Builds with Gradle by Ryan Cuprak
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
Ryan Cuprak1.9K views
Development Horror Stories by Roberto Cortez
Development Horror StoriesDevelopment Horror Stories
Development Horror Stories
Roberto Cortez8.5K views
Java. Lecture 01. Introducing Java by colriot
Java. Lecture 01. Introducing JavaJava. Lecture 01. Introducing Java
Java. Lecture 01. Introducing Java
colriot812 views
Open Source - Bзгляд из вражeскoгo лагeря by Andrew Zaikin
Open Source - Bзгляд из вражeскoгo лагeряOpen Source - Bзгляд из вражeскoгo лагeря
Open Source - Bзгляд из вражeскoгo лагeря
Andrew Zaikin420 views
Kathy Barton - Letter of Recommendation Odyssey Healthcare of Chicago by Michele Cuprak
Kathy Barton - Letter of Recommendation Odyssey Healthcare of ChicagoKathy Barton - Letter of Recommendation Odyssey Healthcare of Chicago
Kathy Barton - Letter of Recommendation Odyssey Healthcare of Chicago
Michele Cuprak59 views
South Suburban College Dean's List by Michele Cuprak
South Suburban College  Dean's ListSouth Suburban College  Dean's List
South Suburban College Dean's List
Michele Cuprak84 views
2016 Letter of Recommendation from CVR Charmaine Johnson-Davis Senior Vice Pr... by Michele Cuprak
2016 Letter of Recommendation from CVR Charmaine Johnson-Davis Senior Vice Pr...2016 Letter of Recommendation from CVR Charmaine Johnson-Davis Senior Vice Pr...
2016 Letter of Recommendation from CVR Charmaine Johnson-Davis Senior Vice Pr...
Michele Cuprak96 views
Munster Med-Inn Letter of Recommendaton - Copy by Michele Cuprak
Munster Med-Inn Letter of Recommendaton - CopyMunster Med-Inn Letter of Recommendaton - Copy
Munster Med-Inn Letter of Recommendaton - Copy
Michele Cuprak72 views
Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object... by CocoaHeads
Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object...Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object...
Встреча №9. Алгоритмы и коллекции стандартных библиотек C++, C#, Java, Object...
CocoaHeads2.4K views
Java on zSystems zOS by Tim Ellison
Java on zSystems zOSJava on zSystems zOS
Java on zSystems zOS
Tim Ellison4.9K views
20 most important java programming interview questions by Gradeup
20 most important java programming interview questions20 most important java programming interview questions
20 most important java programming interview questions
Gradeup2.9K views
Java script nirvana in netbeans [con5679] by Ryan Cuprak
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
Ryan Cuprak1.1K views

Similar to Batching and Java EE (jdk.io)

Spring batch by
Spring batchSpring batch
Spring batchChandan Kumar Rana
456 views25 slides
Spring Batch by
Spring BatchSpring Batch
Spring BatchJayasree Perilakkalam
247 views16 slides
Spring batch showCase by
Spring batch showCaseSpring batch showCase
Spring batch showCasetaher abdo
99 views18 slides
Java Batch by
Java BatchJava Batch
Java BatchSoftware Infrastructure
429 views44 slides
Play Framework and Activator by
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
4.1K views47 slides
Elements for an iOS Backend by
Elements for an iOS BackendElements for an iOS Backend
Elements for an iOS BackendLaurent Cerveau
1K views41 slides

Similar to Batching and Java EE (jdk.io)(20)

Spring batch showCase by taher abdo
Spring batch showCaseSpring batch showCase
Spring batch showCase
taher abdo99 views
Play Framework and Activator by Kevin Webber
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
Kevin Webber4.1K views
Spring Batch Performance Tuning by Gunnar Hillert
Spring Batch Performance TuningSpring Batch Performance Tuning
Spring Batch Performance Tuning
Gunnar Hillert12.3K views
Build Java Web Application Using Apache Struts by weili_at_slideshare
Build Java Web Application Using Apache Struts Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts
weili_at_slideshare1.8K views
WebObjects Optimization by WO Community
WebObjects OptimizationWebObjects Optimization
WebObjects Optimization
WO Community2.3K views
AAI 1713-Introduction to Java EE 7 by Kevin Sutter
AAI 1713-Introduction to Java EE 7AAI 1713-Introduction to Java EE 7
AAI 1713-Introduction to Java EE 7
Kevin Sutter459 views
Parallel batch processing with spring batch slideshare by Morten Andersen-Gott
Parallel batch processing with spring batch   slideshareParallel batch processing with spring batch   slideshare
Parallel batch processing with spring batch slideshare
Morten Andersen-Gott15.9K views
DjangoCon 2010 Scaling Disqus by zeeg
DjangoCon 2010 Scaling DisqusDjangoCon 2010 Scaling Disqus
DjangoCon 2010 Scaling Disqus
zeeg32.6K views
Priority enabled wps by 52North
Priority enabled wpsPriority enabled wps
Priority enabled wps
52North1K views
SeaJUG May 2012 mybatis by Will Iverson
SeaJUG May 2012 mybatisSeaJUG May 2012 mybatis
SeaJUG May 2012 mybatis
Will Iverson2.2K views
SharePoint 2013 Performance Analysis - Robi Vončina by SPC Adriatics
SharePoint 2013 Performance Analysis - Robi VončinaSharePoint 2013 Performance Analysis - Robi Vončina
SharePoint 2013 Performance Analysis - Robi Vončina
SPC Adriatics6.5K views

More from Ryan Cuprak

Jakarta EE Test Strategies (2022) by
Jakarta EE Test Strategies (2022)Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)Ryan Cuprak
12 views89 slides
DIY Home Weather Station (Devoxx Poland 2023) by
DIY Home Weather Station (Devoxx Poland 2023)DIY Home Weather Station (Devoxx Poland 2023)
DIY Home Weather Station (Devoxx Poland 2023)Ryan Cuprak
99 views83 slides
Why jakarta ee matters (ConFoo 2021) by
Why jakarta ee matters (ConFoo 2021)Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)Ryan Cuprak
221 views62 slides
Polygot Java EE on the GraalVM by
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVMRyan Cuprak
1K views49 slides
Exploring Java Heap Dumps (Oracle Code One 2018) by
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Ryan Cuprak
2K views69 slides
Node.js Development with Apache NetBeans by
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeansRyan Cuprak
5.5K views44 slides

More from Ryan Cuprak(16)

Jakarta EE Test Strategies (2022) by Ryan Cuprak
Jakarta EE Test Strategies (2022)Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)
Ryan Cuprak12 views
DIY Home Weather Station (Devoxx Poland 2023) by Ryan Cuprak
DIY Home Weather Station (Devoxx Poland 2023)DIY Home Weather Station (Devoxx Poland 2023)
DIY Home Weather Station (Devoxx Poland 2023)
Ryan Cuprak99 views
Why jakarta ee matters (ConFoo 2021) by Ryan Cuprak
Why jakarta ee matters (ConFoo 2021)Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)
Ryan Cuprak221 views
Polygot Java EE on the GraalVM by Ryan Cuprak
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
Ryan Cuprak1K views
Exploring Java Heap Dumps (Oracle Code One 2018) by Ryan Cuprak
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
Ryan Cuprak2K views
Node.js Development with Apache NetBeans by Ryan Cuprak
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
Ryan Cuprak5.5K views
Preparing for java 9 modules upload by Ryan Cuprak
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
Ryan Cuprak1.7K views
Faster Java EE Builds with Gradle by Ryan Cuprak
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
Ryan Cuprak492 views
Faster java ee builds with gradle [con4921] by Ryan Cuprak
Faster java ee builds with gradle [con4921]Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]
Ryan Cuprak2.4K views
Developing in the Cloud by Ryan Cuprak
Developing in the CloudDeveloping in the Cloud
Developing in the Cloud
Ryan Cuprak1.1K views
Combining R With Java For Data Analysis (Devoxx UK 2015 Session) by Ryan Cuprak
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
Combining R With Java For Data Analysis (Devoxx UK 2015 Session)
Ryan Cuprak3.6K views
Hybrid Mobile Development with Apache Cordova and by Ryan Cuprak
Hybrid Mobile Development with Apache Cordova and Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and
Ryan Cuprak1.9K views
JavaFX Versus HTML5 - JavaOne 2014 by Ryan Cuprak
JavaFX Versus HTML5 - JavaOne 2014JavaFX Versus HTML5 - JavaOne 2014
JavaFX Versus HTML5 - JavaOne 2014
Ryan Cuprak14.9K views
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014 by Ryan Cuprak
50 EJB 3 Best Practices in 50 Minutes - JavaOne 201450 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
50 EJB 3 Best Practices in 50 Minutes - JavaOne 2014
Ryan Cuprak33K views
JavaOne 2013: Organizing Your Local Community by Ryan Cuprak
JavaOne 2013: Organizing Your Local CommunityJavaOne 2013: Organizing Your Local Community
JavaOne 2013: Organizing Your Local Community
Ryan Cuprak811 views

Recently uploaded

Generic or specific? Making sensible software design decisions by
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
6 views60 slides
Airline Booking Software by
Airline Booking SoftwareAirline Booking Software
Airline Booking SoftwareSharmiMehta
6 views26 slides
FOSSLight Community Day 2023-11-30 by
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30Shane Coughlan
5 views18 slides
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... by
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Marc Müller
41 views83 slides
Copilot Prompting Toolkit_All Resources.pdf by
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdfRiccardo Zamana
10 views4 slides
The Era of Large Language Models.pptx by
The Era of Large Language Models.pptxThe Era of Large Language Models.pptx
The Era of Large Language Models.pptxAbdulVahedShaik
6 views9 slides

Recently uploaded(20)

Generic or specific? Making sensible software design decisions by Bert Jan Schrijver
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta6 views
FOSSLight Community Day 2023-11-30 by Shane Coughlan
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30
Shane Coughlan5 views
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI... by Marc Müller
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Dev-Cloud Conference 2023 - Continuous Deployment Showdown: Traditionelles CI...
Marc Müller41 views
Copilot Prompting Toolkit_All Resources.pdf by Riccardo Zamana
Copilot Prompting Toolkit_All Resources.pdfCopilot Prompting Toolkit_All Resources.pdf
Copilot Prompting Toolkit_All Resources.pdf
Riccardo Zamana10 views
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ... by Donato Onofri
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Donato Onofri860 views
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action by Márton Kodok
Gen Apps on Google Cloud PaLM2 and Codey APIs in ActionGen Apps on Google Cloud PaLM2 and Codey APIs in Action
Gen Apps on Google Cloud PaLM2 and Codey APIs in Action
Márton Kodok6 views
Sprint 226 by ManageIQ
Sprint 226Sprint 226
Sprint 226
ManageIQ5 views
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by Ra'Fat Al-Msie'deen
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsBushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with... by sparkfabrik
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
20231129 - Platform @ localhost 2023 - Application-driven infrastructure with...
sparkfabrik7 views
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra... by Marc Müller
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra....NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
.NET Developer Conference 2023 - .NET Microservices mit Dapr – zu viel Abstra...
Marc Müller40 views
Headless JS UG Presentation.pptx by Jack Spektor
Headless JS UG Presentation.pptxHeadless JS UG Presentation.pptx
Headless JS UG Presentation.pptx
Jack Spektor8 views
Dapr Unleashed: Accelerating Microservice Development by Miroslav Janeski
Dapr Unleashed: Accelerating Microservice DevelopmentDapr Unleashed: Accelerating Microservice Development
Dapr Unleashed: Accelerating Microservice Development
Miroslav Janeski10 views

Batching and Java EE (jdk.io)

  • 2. What is Batch Processing? Batch jobs are typically: • Bulk-oriented • Non-interactive • Potentially compute intensive • May require parallel execution • Maybe invoked, ad hoc, scheduled, on-demand etc.
  • 3. Batching Examples • Monthly reports/statements • Daily data cleanup • One-time data migrations • Data synchronization • Data analysis • Portfolio rebalancing
  • 4. Introducing Java EE Batching • Introduced in Java EE 7 • JSR 352 - https://jcp.org/en/jsr/detail?id=352 • Reference implementation: https://github.com/WASdev/standards.jsr352.jbatch • Batch Framework: • Batch container for execution of jobs • XML Job Specification Language • Batch annotations and interfaces • Supporting classes and interfaces for interacting with the container • Depends on CDI
  • 5. Java EE Batching Overview JobOperator Job Step JobRepository ItemReader ItemProcessor ItemWriter 1 * 1 1 1 1 1 1
  • 6. Java EE Batching Overview JobInstance Job JobExecution * * EndOfDayJob EndOfDayJob for 9/1/2016 First attempt at EndOfDay job for 9/1/2016
  • 7. Java EE Batching Features • Fault-tolerant – checkpoints and job persistence • Transactions - chunks execute within a JTA transaction • Listeners – notification of job status/completion/etc. • Resource management – limits concurrent jobs • Starting/stopping/restarting – job control API
  • 8. Java EE Batching Deployment WAR EAR JAR Deploy batch jobs in: Manage jobs – split application into modules Server B app.war End of Day Job Cleanup Job Server C app2.war Analytics Job Server A frontend.war
  • 10. Exit Codes Code Description STARTING Job has been submitted to runtime. STARTED Batch job has started executing. STOPPING Job termination has been requested. STOPPED Job has been stopped. FAILED Job has thrown an error or failured triggered by <failure> COMPLETED Job has completed normally. ABANDONDED Job cannot be restarted
  • 11. Basic Layout CDI Configuration Job Configuration Batchlet
  • 14. Batchlet with Termination Jobs should implement and terminate when requested!
  • 17. IDs and Names instanceId • ID represents an instance of a job. • Created when JobOperator start method invoked. executionId • ID that represents the next attempt to run a particular job instance. • Created when a job is started/restarted. • Only one executionId for a job can be started at a time stepExecutionId • ID for an attempt to execute a particular step in a job jobName • name of the job from XML (actually id) <job id=“”> jobXMLName • name of the config file in META-INF/batch-jobs
  • 18. JobInstance vs. JobExecution JobInstance JobExecution 1 * • BatchStatus • createTime • endTime • executionID • exitStatus • jobName • jobParameters, lastUpdateTime • startTime • instanceId • jobName
  • 19. Managing Jobs • JobOperator – interface for operating on batch jobs. • BatchRuntime.getJobOperator() • JobOperator: • Provides information on current and completed jobs • Used to start/stop/restart/abandon jobs • Security is implementation dependent • JobOperator interacts with JobRepository • JobRepository • Implementation out-side scope of JSR • No API for deleting old jobs • Reference implementation provides no API for cleanup!
  • 20. JobOperator Methods Type Method void Abandon(long executionId) JobExecution getJobExecution(long executionId) List<JobExecution> getJobExecutions(JobInstance instance) JobInstance getJobInstance(long executionId) int getJobInstanceCount(String jobName) List<JobInstance> getJobInstances(String jobName,int start, in count) Set<String> getJobNames() Properties getParameters(long executionId) List<Long> getRunningExecutions(String jobName) List<StepExecution> getStepExecutions(long jobExecutionId) long Restart(long executionId, Properties restartParams) long start(String jobXMLName, Properties jobParams) void Stop(long executionId)
  • 22. Chunking • Chunking is primary pattern for batch processing in JSR- 352. • Encapsulates the ETL pattern: • Pieces: Reader/Processor/Writer • Reader/Processor invoked until an entire chuck of data is processed. • Output is written atomically • Implementation: • Interfaces: ItemReader/ItemWriter/ItemProcessor • Classes: AbstractReader/AbstractWriter/AbstractProcessor Reader Processor Writer
  • 24. Chunk Configuration Parameter Description checkpoint-policy Possible values: item or custom item-count Number of items to be processed per chunk. Default is 10. time-limit Time in seconds before taking a checkpoint. Default is 0 (means after each chunk) skip-limit Number of exceptions a step will skip if there are configured skippable exceptions. retry-limit Number of times a step will be retried if it has throw a skippable exception.
  • 26. Chunking Step ItemReader ItemProcessor ItemWriter read() item process(item) item read() item process(item) item write(items) execute() ExitStatus
  • 30. Demo
  • 33. Step Exceptions • Parallel running instances (partition) complete before the job completes. • Batch status transitions to FAILED
  • 42. Split updateExisting processNewStorms Flow & Splits JCL • <flow> element is used to implement process workflows. • <split> element is used to run jobs in parallel retrieveTracking processDecider stormReader stormProcessor stormWriter updateExisting Storms
  • 46. Hadoop Overview • Massively scalable storage and batch data processing system • Written in Java • Huge ecosystem • Meant for massive data processing jobs • Horizontally scalable • Uses MapReduce programming model • Handles processing of petabytes of data • Started at Yahoo! In 2005.
  • 48. Hadoop Typically Hadoop is used when: • Analysis is performed on unstructured datasets • Data is stored across multiple servers (HDFS) • Non-Java processes are fed data and managed Ex. https://svi.nl/HuygensSoftware
  • 49. Spring vs. Java EE Batching • Spring Batch 3.0 implements JSR-352! • Batch artifacts developed against JSR-352 won’t work within a traditional Spring Batch Job • Same two processing models as Spring Batch: • Item – aka chunking • Task - aka Batchlet
  • 50. Terminology Comparison JSR-352 Spring Batch Job Job Step Step Chunk Chunk Item Item ItemReader ItemReader/ItemStream ItemProcessor ItemProcessor ItemWriter ItemWriter/ItemStream JobInstance JobInstance JobExecution JobExecution StepExecution StepExecution JobListener JobExecutionListener StepListener StepExecutionListener
  • 51. Scaling Batch Jobs • Traditional Spring Batch Scaling: • Split – running multiple steps in parallel • Multiple threads – executing a single step via multiple threads • Partitioning – dividing data up for parallel processing • Remote Chunking – executing the processor logic remotely • JSR-352 Job Scaling • Split – running multiple steps in parallel • Partitioning – dividing data up – implementation slightly different.
  • 52. JSR-352/Spring/Hadoop Hadoop • Massively parallel / large jobs • Processing petabytes of data (BIG DATA) JSR-352/Spring • Traditional batch processing jobs • Structured data/business processes JSR-352 vs. Spring • Java EE versus Spring containers • Spring has better job scaling capabilities
  • 53. JSR-352 Implementations • JBeret • http://tinyurl.com/z4qx3wo • WebSphere/WebLogic/Payara • jbatch (reference) • http://tinyurl.com/jk6vcb8 • WildFly/JBoss • SpringBatch • http://tinyurl.com/mt8v3k7
  • 54. Best Practices • Package/deploy batch jobs separately • Implement logic to cleanup old jobs • Implement logic for auto-restart • Test restart and checkpoint logic • Configure database to store jobs • Configure thread pool for batch jobs • Only invoke batch jobs from logic that is secured (@Role etc.)
  • 55. Resources • JSR-352 https://jcp.org/en/jsr/detail?id=352 • Java EE Support http://javaee.support/contributors/ • Spring Batch http://docs.spring.io/spring-batch/reference/html/spring-batch- intro.html • Spring JSR-352 Support http://docs.spring.io/spring-batch/reference/html/jsr-352.html
  • 56. Resources • Java EE 7 Batch Processing and World of Warcraft http://tinyurl.com/gp8yls8 • Three Key Concepts for Understanding JSR-352 http://tinyurl.com/oxe2dhu • Java EE Tutorial https://docs.oracle.com/javaee/7/tutorial/batch- processing.htm

Editor's Notes

  1. I would like to welcome everybody to
  2. We’ve got our class, next we need to create a XML configuration file for the job.
  3. Starting a job is relatively easy. We access the batch runtime and get a job operator. Initialize properties, which would contain configuration settings. Start the job – the “simpleJob”