SlideShare une entreprise Scribd logo
1  sur  47
Télécharger pour lire hors ligne
Java 
EE 
7 
Batch 
Processing 
in 
the 
Real 
World 
Roberto 
Cortez 
& 
Ivan 
St. 
Ivanov 
JavaOne 
2014 
#CON2818
Who 
are 
we? 
Roberto 
Cortez 
@radcortez 
h/p://www.radcortez.com 
Freelancer, 
Speaker, 
RebelLabs 
Author, 
Blogger 
Ivan 
St. 
Ivanov 
@ivan_stefanov 
h/p://nosoGskills.com 
Architect, 
SAP 
Labs 
Bulgaria, 
JBoss 
Forge 
contributor
QuesHons? 
As 
soon 
as 
you 
have 
them!
What 
is 
Batch? 
“A 
group 
of 
records 
processed 
as 
a 
single 
unit, 
usually 
without 
input 
from 
a 
user.” 
(from 
Google)
Why 
Batch? 
(Computers) 
• Make 
use 
of 
idle 
resources 
• ShiT 
the 
Hme 
of 
processing 
• Manage 
large 
repeated 
work 
easily 
• Shared 
by 
mulHple 
users
Batch 
is 
in 
our 
lives 
• By 
paying 
bills 
• On 
the 
grocery 
• In 
traffic 
• Cooking 
food
Why 
Batch? 
(General) 
• Efficiency 
• Focus 
on 
a 
single 
problem 
• Avoid 
context 
switch 
• Reduce 
costs
State 
of 
the 
Art 
• Spring 
Batch 
• IBM 
Websphere 
• Hadoop 
• Java 
SE, 
Scheduler, 
in-­‐house 
frameworks
The 
JSR-­‐352 
• Batch 
ApplicaHons 
for 
the 
Java 
pla]orm 
• Heavily 
inspired 
by 
Spring 
Batch 
• Available 
since 
Java 
EE 
7 
• Also 
designed 
for 
Java 
SE
The 
JSR-­‐352 
Features 
• Task 
and 
Chunk 
oriented 
processing 
• SequenHal 
and/or 
Parallel 
execuHon 
• CheckpoinHng 
• Workflow 
• Stop 
and 
restart 
• ExcepHon 
handling
Batch 
Domain 
Language 
Job 
Operator 
Job 
Step 
Job 
Repository 
Item 
Reader 
Item 
Processor 
Item 
Writer 
1 
*
Job 
composiYon 
* 
Job 
Step 
* 
JobInstance 
* 
* 
* 
JobExecuYon 
StepExecuYon
Java 
EE 
Batch 
API
Batchlet 
DefiniYon 
@Named 
public 
class 
MyBatchlet 
extends 
AbstractBatchlet 
{ 
@Override 
public 
String 
process() 
{ 
System.out.println("Running 
inside 
a 
batchlet"); 
return 
BatchStatus.COMPLETED.toString(); 
} 
}
Job 
SpecificaYon 
Language 
<job 
id="myFirstBatch"> 
<step 
id="myStep" 
> 
<batchlet 
ref="myBatchlet"/> 
</step> 
</job>
Start 
the 
Job 
JobOperator 
jobOperator 
= 
BatchRunYme.getJobOperator(); 
Long 
execuYonId 
= 
jobOperator.start("myJob", 
new 
ProperYes()); 
JobExecuYon 
jobExecuYon 
= 
jobOperator.getJobExecuYon(execuYonId);
Batchlet 
• Task 
oriented 
Batch 
Step 
• Suitable 
for 
• Short 
execuHons 
• Handle 
system 
resources 
• IniHalizaHon 
and 
Cleanup
Chunk 
• ETL 
style 
(Reader, 
Processor, 
Writer) 
• Suitable 
for 
• Handle 
large 
amounts 
of 
data 
• Failover 
safety 
(checkpoint) 
• Long 
running 
applicaHons
Chunk 
Processing 
Step 
ItemReader 
ItemProcessor 
ItemWriter 
read() 
read() 
process(item) 
process(item) 
write(items) 
item 
item 
item 
item 
execute() 
ExitStatus
Defining 
Chunk 
Step 
<step 
id="myChunk"> 
<chunk 
checkpoint-­‐policy="item" 
item-­‐count="3"> 
<reader 
ref=“myItemReader"/> 
<processor 
ref=“myItemProcessor"/> 
<writer 
ref=“myItemWriter"/> 
</chunk> 
</step>
Item 
Reader 
@Named 
public 
class 
MyItemReader 
extends 
AbstractItemReader 
{ 
public 
Object 
readItem() 
throws 
ExcepYon 
{…} 
}
Item 
Processor 
@Named 
public 
class 
MyItemProcessor 
implements 
ItemProcessor 
{ 
public 
Object 
processItem(Object 
item) 
throws 
ExcepYon 
{…} 
}
Item 
Writer 
@Named 
public 
class 
MyItemWriter 
extends 
AbstractItemWriter 
{ 
public 
void 
writeItems(List<Object> 
items) 
throws 
ExcepYon 
{…} 
}
ExcepYon 
Handling 
• Job 
ExecuHon 
Fails 
on 
ExcepHon 
• Possible 
to 
Skip 
or 
Retry 
ExcepHons 
• Applied 
to 
the 
Chunk 
• Include 
or 
Exclude 
ExcepHons
ExcepYon 
Handling 
DefiniYon 
<chunk 
checkpoint-­‐policy="item” 
item-­‐count="3" 
skip-­‐limit="3" 
retry-­‐limit="3"> 
<reader 
ref="myItemReader"/> 
<processor 
ref="myItemProcessor"/> 
<writer 
ref="myItemWriter"/> 
<skippable-­‐excepYon-­‐classes> 
<include 
class="java.lang.RunYmeExcepYon"/> 
</skippable-­‐excepYon-­‐classes> 
<retryable-­‐excepYon-­‐classes> 
<exclude 
class="java.lang.IllegalArgumentExcepYon"/> 
</retryable-­‐excepYon-­‐classes> 
</chunk>
ParYYon 
• Steps 
run 
on 
mulHple 
Threads 
• One 
ParHHon 
per 
Thread 
• Define 
ParHHon 
Plan 
• CheckpoinHng 
is 
independent 
per 
Thread
ParYYon 
DefiniYon 
(In 
Step) 
<parYYon> 
<plan 
parYYons="2"> 
<properYes 
parYYon="0"> 
<property 
name="start" 
value="1"/> 
</properYes> 
<properYes 
parYYon="1"> 
<property 
name="start" 
value="11"/> 
</properYes> 
</plan> 
</parYYon>
ParYYon 
DefiniYon 
(In 
Step) 
<chunk 
item-­‐count="3"> 
<reader 
ref="myItemReader"> 
<properYes> 
<property 
name="start” 
value="#{parYYonPlan['start']}" 
/> 
</properYes> 
</reader> 
<processor 
ref="myItemProcessor"/> 
<writer 
ref="myItemWriter"/> 
</chunk>
Flow 
• Sequence 
of 
ExecuHon 
elements 
• Execute 
together 
as 
a 
unit 
• Flows, 
Steps, 
Decision 
and 
Split 
• Used 
to 
aggregate 
logical 
business.
Split 
• Concurrent 
ExecuHon 
of 
Flows 
• Each 
Flow 
run 
on 
a 
separate 
Thread 
• Is 
not 
the 
same 
as 
a 
ParHHon 
• Can 
only 
use 
Flows
Split 
and 
Flow 
DefiniYon 
<split 
id="mySplit"> 
<flow 
id="flow1"> 
<step 
id="myChunk" 
next="myBatchlet”>…</step> 
<step 
id="myBatchlet">...</step> 
</flow> 
<flow 
id="flow2"> 
<step 
id=”otherChunk" 
next=”otherBatchlet”>…</step> 
<step 
id=”otherBatchlet">...</step> 
</flow> 
</split>
ParYYon 
vs 
Split 
• ParHHon 
is 
used 
at 
the 
data 
level 
• Split 
is 
used 
at 
the 
business 
level
Decision 
• Decide 
the 
next 
TransiHon 
• Applied 
to 
Steps, 
Flows 
and 
Splits 
• It’s 
almost 
like 
an 
if 
/ 
else 
if 
• Requires 
an 
implementaHon
Decision 
DefiniYon 
<step 
id=”myStep" 
next="myDecider"> 
<batchlet 
ref="myBatchlet”/> 
</step> 
<decision 
id="myDecider" 
ref="MyDecider"> 
<next 
on="foo" 
to="myFooStep"/> 
<next 
on="bar" 
to="myBarStep"/> 
</decision>
Decision 
@Named 
public 
class 
MyDecider 
implements 
Decider 
{ 
public 
String 
decide(StepExecuYon[] 
execuYons) 
throws 
ExcepYon 
{…} 
}
TransiYons 
• TransiHon 
Elements 
define 
the 
Workflow 
• Applied 
to 
Steps, 
Flows 
and 
Decision 
• Next, 
Fail, 
End, 
Stop 
• Fail, 
End 
and 
Stop 
terminate 
a 
Job
Batch 
Exit 
Status 
• A 
Job 
and 
Steps 
has 
an 
Exit 
Status 
• Used 
to 
control 
the 
Workflow 
• STARTING, 
STARTED, 
STOPPING, 
STOPPED, 
FAILED, 
COMPLETED, 
ABANDONED
Schedule 
a 
Job 
(By 
@Schedule) 
@Singleton 
public 
class 
BatchJobRunner 
{ 
@Schedule(dayOfWeek 
= 
"Sun") 
public 
void 
scheduleJob() 
{ 
JobOperator 
jobOperator 
= 
BatchRunYme.getJobOperator(); 
jobOperator.start("myJob", 
new 
ProperYes()); 
} 
}
Schedule 
a 
Job 
(By 
ManagedScheduledExecutorService) 
@Resource(lookup="java:comp/DefaultManagedScheduledExecutorService") 
private 
ManagedScheduledExecutorService 
executor; 
public 
void 
scheduleJob() 
{ 
JobOperator 
jobOperator 
= 
BatchRunYme.getJobOperator(); 
executor.schedule( 
() 
-­‐> 
jobOperator.start("myJob", 
new 
ProperYes()), 
7, 
TimeUnit.DAYS); 
}
ImplementaYons 
• JBatch 
IBM 
(Glassfish, 
JEUS) 
• JBeret 
(Wildfly) 
• Spring 
Batch
A 
Few 
Cons 
• Lacks 
standard 
Readers 
/ 
Writers 
• No 
Generics 
• ParHHon 
only 
supports 
a 
single 
Step 
• No 
Sync 
mode
Demo 
Time
WoW 
AucYon 
House 
• World 
of 
WacraT 
is 
MMORPG 
• More 
than 
500 
servers 
in 
US 
and 
EU 
• Each 
server 
has 
2 
AucHon 
Houses 
• Trades 
around 
70k 
items 
/ 
server 
/ 
hour
WoW 
AucYon 
House 
• Data 
available 
to 
download 
• Let’s 
process 
the 
data 
• Extract 
metrics 
• Share 
the 
knowledge
Live 
Code
Resources 
• JSR-­‐352 
SpecificaHon 
hips://jcp.org/en/jsr/detail?id=352 
• Java 
EE 
Samples 
hips://github.com/javaee-­‐samples 
• Wow 
AucHon 
House 
hips://github.com/radcortez/wow-­‐aucHons
Thank 
you 
for 
A/ending! 
Roberto 
Cortez 
@radcortez 
h/p://www.radcortez.com 
Ivan 
St. 
Ivanov 
@ivan_stefanov 
h/p://nosoGskills.com

Contenu connexe

Tendances

NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystemYukti Kaura
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.jsVikash Singh
 
1장 Java란 무엇인가.key
1장 Java란 무엇인가.key1장 Java란 무엇인가.key
1장 Java란 무엇인가.key김 한도
 
Java Servlets
Java ServletsJava Servlets
Java ServletsEmprovise
 
Spring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSpring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSam Brannen
 
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafSpring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafThymeleaf
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js ExpressEyal Vardi
 
Java EE Introduction
Java EE IntroductionJava EE Introduction
Java EE Introductionejlp12
 
Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19José Paumard
 
Modern Java web applications with Spring Boot and Thymeleaf
Modern Java web applications with Spring Boot and ThymeleafModern Java web applications with Spring Boot and Thymeleaf
Modern Java web applications with Spring Boot and ThymeleafLAY Leangsros
 
Creating a Data Driven UI Framework
Creating a Data Driven UI FrameworkCreating a Data Driven UI Framework
Creating a Data Driven UI FrameworkAnkur Bansal
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate pptAneega
 
Hibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance TechniquesHibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance TechniquesBrett Meyer
 
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMJava Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMshamnasain
 

Tendances (20)

Oraclesql
OraclesqlOraclesql
Oraclesql
 
NodeJS ecosystem
NodeJS ecosystemNodeJS ecosystem
NodeJS ecosystem
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
1장 Java란 무엇인가.key
1장 Java란 무엇인가.key1장 Java란 무엇인가.key
1장 Java란 무엇인가.key
 
Jaxb
JaxbJaxb
Jaxb
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Spring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing SupportSpring 3.1 and MVC Testing Support
Spring 3.1 and MVC Testing Support
 
Laravel overview
Laravel overviewLaravel overview
Laravel overview
 
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafSpring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
Java EE Introduction
Java EE IntroductionJava EE Introduction
Java EE Introduction
 
Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19
 
Modern Java web applications with Spring Boot and Thymeleaf
Modern Java web applications with Spring Boot and ThymeleafModern Java web applications with Spring Boot and Thymeleaf
Modern Java web applications with Spring Boot and Thymeleaf
 
Creating a Data Driven UI Framework
Creating a Data Driven UI FrameworkCreating a Data Driven UI Framework
Creating a Data Driven UI Framework
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
Hibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance TechniquesHibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance Techniques
 
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMJava Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
 
Drools rule Concepts
Drools rule ConceptsDrools rule Concepts
Drools rule Concepts
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 

Similaire à Java EE 7 Batch processing in the Real World

50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 201450 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014Arun Gupta
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nationArun Gupta
 
50 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 201450 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 2014Arun Gupta
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevMattias Karlsson
 
Spring Batch Workshop
Spring Batch WorkshopSpring Batch Workshop
Spring Batch Workshoplyonjug
 
Javazone 2019 - Mutants to the rescue: How effective are your unit tests?
Javazone 2019 - Mutants to the rescue: How effective are your unit tests?Javazone 2019 - Mutants to the rescue: How effective are your unit tests?
Javazone 2019 - Mutants to the rescue: How effective are your unit tests?Paco van Beckhoven
 
50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutesArun Gupta
 
Effiziente persistierung
Effiziente persistierungEffiziente persistierung
Effiziente persistierungThorben Janssen
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemAndres Almiray
 
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013Arun Gupta
 
Code transformation With Spoon
Code transformation With SpoonCode transformation With Spoon
Code transformation With SpoonGérard Paligot
 
Javatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparisonJavatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparisonJini Lee
 
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateThorben Janssen
 

Similaire à Java EE 7 Batch processing in the Real World (20)

Spring batch
Spring batchSpring batch
Spring batch
 
Spring Batch
Spring BatchSpring Batch
Spring Batch
 
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 201450 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
50 New Features of Java EE 7 in 50 minutes @ Devoxx France 2014
 
5050 dev nation
5050 dev nation5050 dev nation
5050 dev nation
 
50 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 201450 features of Java EE 7 in 50 minutes at Geecon 2014
50 features of Java EE 7 in 50 minutes at Geecon 2014
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Spring Batch Workshop
Spring Batch WorkshopSpring Batch Workshop
Spring Batch Workshop
 
Javazone 2019 - Mutants to the rescue: How effective are your unit tests?
Javazone 2019 - Mutants to the rescue: How effective are your unit tests?Javazone 2019 - Mutants to the rescue: How effective are your unit tests?
Javazone 2019 - Mutants to the rescue: How effective are your unit tests?
 
50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes
 
Effiziente persistierung
Effiziente persistierungEffiziente persistierung
Effiziente persistierung
 
Java Batch
Java BatchJava Batch
Java Batch
 
vJUG - The JavaFX Ecosystem
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
Java EE 7: Whats New in the Java EE Platform @ Devoxx 2013
 
Spring Batch 2.0
Spring Batch 2.0Spring Batch 2.0
Spring Batch 2.0
 
JS Essence
JS EssenceJS Essence
JS Essence
 
Code transformation With Spoon
Code transformation With SpoonCode transformation With Spoon
Code transformation With Spoon
 
Javatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparisonJavatwo2012 java frameworkcomparison
Javatwo2012 java frameworkcomparison
 
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
 
Struts2 - 101
Struts2 - 101Struts2 - 101
Struts2 - 101
 

Plus de Roberto Cortez

Chasing the RESTful Trinity - Client CLI and Documentation
Chasing the RESTful Trinity - Client CLI and DocumentationChasing the RESTful Trinity - Client CLI and Documentation
Chasing the RESTful Trinity - Client CLI and DocumentationRoberto Cortez
 
Baking a Microservice PI(e)
Baking a Microservice PI(e)Baking a Microservice PI(e)
Baking a Microservice PI(e)Roberto Cortez
 
GraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices SolutionGraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices SolutionRoberto Cortez
 
Deconstructing and Evolving REST Security
Deconstructing and Evolving REST SecurityDeconstructing and Evolving REST Security
Deconstructing and Evolving REST SecurityRoberto Cortez
 
Lightweight Enterprise Java With Microprofile
Lightweight Enterprise Java With MicroprofileLightweight Enterprise Java With Microprofile
Lightweight Enterprise Java With MicroprofileRoberto Cortez
 
Cluster your MicroProfile Application using CDI and JCache
Cluster your MicroProfile Application using CDI and JCacheCluster your MicroProfile Application using CDI and JCache
Cluster your MicroProfile Application using CDI and JCacheRoberto Cortez
 
Java EE 7 meets Java 8
Java EE 7 meets Java 8Java EE 7 meets Java 8
Java EE 7 meets Java 8Roberto Cortez
 
Maven - Taming the Beast
Maven - Taming the BeastMaven - Taming the Beast
Maven - Taming the BeastRoberto Cortez
 
The First Contact with Java EE 7
The First Contact with Java EE 7The First Contact with Java EE 7
The First Contact with Java EE 7Roberto Cortez
 
Migration tales from java ee 5 to 7
Migration tales from java ee 5 to 7Migration tales from java ee 5 to 7
Migration tales from java ee 5 to 7Roberto Cortez
 
Development Horror Stories
Development Horror StoriesDevelopment Horror Stories
Development Horror StoriesRoberto Cortez
 
The 5 People in your Organization that grow Legacy Code
The 5 People in your Organization that grow Legacy CodeThe 5 People in your Organization that grow Legacy Code
The 5 People in your Organization that grow Legacy CodeRoberto Cortez
 
Geecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
Geecon 2014 - Five Ways to Not Suck at Being a Java FreelancerGeecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
Geecon 2014 - Five Ways to Not Suck at Being a Java FreelancerRoberto Cortez
 
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7Roberto Cortez
 
Coimbra JUG - 1º Encontro - As novidades do Java 8
Coimbra JUG - 1º Encontro - As novidades do Java 8Coimbra JUG - 1º Encontro - As novidades do Java 8
Coimbra JUG - 1º Encontro - As novidades do Java 8Roberto Cortez
 

Plus de Roberto Cortez (15)

Chasing the RESTful Trinity - Client CLI and Documentation
Chasing the RESTful Trinity - Client CLI and DocumentationChasing the RESTful Trinity - Client CLI and Documentation
Chasing the RESTful Trinity - Client CLI and Documentation
 
Baking a Microservice PI(e)
Baking a Microservice PI(e)Baking a Microservice PI(e)
Baking a Microservice PI(e)
 
GraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices SolutionGraalVM and MicroProfile - A Polyglot Microservices Solution
GraalVM and MicroProfile - A Polyglot Microservices Solution
 
Deconstructing and Evolving REST Security
Deconstructing and Evolving REST SecurityDeconstructing and Evolving REST Security
Deconstructing and Evolving REST Security
 
Lightweight Enterprise Java With Microprofile
Lightweight Enterprise Java With MicroprofileLightweight Enterprise Java With Microprofile
Lightweight Enterprise Java With Microprofile
 
Cluster your MicroProfile Application using CDI and JCache
Cluster your MicroProfile Application using CDI and JCacheCluster your MicroProfile Application using CDI and JCache
Cluster your MicroProfile Application using CDI and JCache
 
Java EE 7 meets Java 8
Java EE 7 meets Java 8Java EE 7 meets Java 8
Java EE 7 meets Java 8
 
Maven - Taming the Beast
Maven - Taming the BeastMaven - Taming the Beast
Maven - Taming the Beast
 
The First Contact with Java EE 7
The First Contact with Java EE 7The First Contact with Java EE 7
The First Contact with Java EE 7
 
Migration tales from java ee 5 to 7
Migration tales from java ee 5 to 7Migration tales from java ee 5 to 7
Migration tales from java ee 5 to 7
 
Development Horror Stories
Development Horror StoriesDevelopment Horror Stories
Development Horror Stories
 
The 5 People in your Organization that grow Legacy Code
The 5 People in your Organization that grow Legacy CodeThe 5 People in your Organization that grow Legacy Code
The 5 People in your Organization that grow Legacy Code
 
Geecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
Geecon 2014 - Five Ways to Not Suck at Being a Java FreelancerGeecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
Geecon 2014 - Five Ways to Not Suck at Being a Java Freelancer
 
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
Coimbra JUG - 2º Encontro - O primeiro contacto com Java EE 7
 
Coimbra JUG - 1º Encontro - As novidades do Java 8
Coimbra JUG - 1º Encontro - As novidades do Java 8Coimbra JUG - 1º Encontro - As novidades do Java 8
Coimbra JUG - 1º Encontro - As novidades do Java 8
 

Dernier

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 

Dernier (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 

Java EE 7 Batch processing in the Real World

  • 1. Java EE 7 Batch Processing in the Real World Roberto Cortez & Ivan St. Ivanov JavaOne 2014 #CON2818
  • 2. Who are we? Roberto Cortez @radcortez h/p://www.radcortez.com Freelancer, Speaker, RebelLabs Author, Blogger Ivan St. Ivanov @ivan_stefanov h/p://nosoGskills.com Architect, SAP Labs Bulgaria, JBoss Forge contributor
  • 3. QuesHons? As soon as you have them!
  • 4. What is Batch? “A group of records processed as a single unit, usually without input from a user.” (from Google)
  • 5. Why Batch? (Computers) • Make use of idle resources • ShiT the Hme of processing • Manage large repeated work easily • Shared by mulHple users
  • 6. Batch is in our lives • By paying bills • On the grocery • In traffic • Cooking food
  • 7. Why Batch? (General) • Efficiency • Focus on a single problem • Avoid context switch • Reduce costs
  • 8. State of the Art • Spring Batch • IBM Websphere • Hadoop • Java SE, Scheduler, in-­‐house frameworks
  • 9. The JSR-­‐352 • Batch ApplicaHons for the Java pla]orm • Heavily inspired by Spring Batch • Available since Java EE 7 • Also designed for Java SE
  • 10. The JSR-­‐352 Features • Task and Chunk oriented processing • SequenHal and/or Parallel execuHon • CheckpoinHng • Workflow • Stop and restart • ExcepHon handling
  • 11. Batch Domain Language Job Operator Job Step Job Repository Item Reader Item Processor Item Writer 1 *
  • 12. Job composiYon * Job Step * JobInstance * * * JobExecuYon StepExecuYon
  • 14. Batchlet DefiniYon @Named public class MyBatchlet extends AbstractBatchlet { @Override public String process() { System.out.println("Running inside a batchlet"); return BatchStatus.COMPLETED.toString(); } }
  • 15. Job SpecificaYon Language <job id="myFirstBatch"> <step id="myStep" > <batchlet ref="myBatchlet"/> </step> </job>
  • 16. Start the Job JobOperator jobOperator = BatchRunYme.getJobOperator(); Long execuYonId = jobOperator.start("myJob", new ProperYes()); JobExecuYon jobExecuYon = jobOperator.getJobExecuYon(execuYonId);
  • 17. Batchlet • Task oriented Batch Step • Suitable for • Short execuHons • Handle system resources • IniHalizaHon and Cleanup
  • 18. Chunk • ETL style (Reader, Processor, Writer) • Suitable for • Handle large amounts of data • Failover safety (checkpoint) • Long running applicaHons
  • 19. Chunk Processing Step ItemReader ItemProcessor ItemWriter read() read() process(item) process(item) write(items) item item item item execute() ExitStatus
  • 20. Defining Chunk Step <step id="myChunk"> <chunk checkpoint-­‐policy="item" item-­‐count="3"> <reader ref=“myItemReader"/> <processor ref=“myItemProcessor"/> <writer ref=“myItemWriter"/> </chunk> </step>
  • 21. Item Reader @Named public class MyItemReader extends AbstractItemReader { public Object readItem() throws ExcepYon {…} }
  • 22. Item Processor @Named public class MyItemProcessor implements ItemProcessor { public Object processItem(Object item) throws ExcepYon {…} }
  • 23. Item Writer @Named public class MyItemWriter extends AbstractItemWriter { public void writeItems(List<Object> items) throws ExcepYon {…} }
  • 24. ExcepYon Handling • Job ExecuHon Fails on ExcepHon • Possible to Skip or Retry ExcepHons • Applied to the Chunk • Include or Exclude ExcepHons
  • 25. ExcepYon Handling DefiniYon <chunk checkpoint-­‐policy="item” item-­‐count="3" skip-­‐limit="3" retry-­‐limit="3"> <reader ref="myItemReader"/> <processor ref="myItemProcessor"/> <writer ref="myItemWriter"/> <skippable-­‐excepYon-­‐classes> <include class="java.lang.RunYmeExcepYon"/> </skippable-­‐excepYon-­‐classes> <retryable-­‐excepYon-­‐classes> <exclude class="java.lang.IllegalArgumentExcepYon"/> </retryable-­‐excepYon-­‐classes> </chunk>
  • 26. ParYYon • Steps run on mulHple Threads • One ParHHon per Thread • Define ParHHon Plan • CheckpoinHng is independent per Thread
  • 27. ParYYon DefiniYon (In Step) <parYYon> <plan parYYons="2"> <properYes parYYon="0"> <property name="start" value="1"/> </properYes> <properYes parYYon="1"> <property name="start" value="11"/> </properYes> </plan> </parYYon>
  • 28. ParYYon DefiniYon (In Step) <chunk item-­‐count="3"> <reader ref="myItemReader"> <properYes> <property name="start” value="#{parYYonPlan['start']}" /> </properYes> </reader> <processor ref="myItemProcessor"/> <writer ref="myItemWriter"/> </chunk>
  • 29. Flow • Sequence of ExecuHon elements • Execute together as a unit • Flows, Steps, Decision and Split • Used to aggregate logical business.
  • 30. Split • Concurrent ExecuHon of Flows • Each Flow run on a separate Thread • Is not the same as a ParHHon • Can only use Flows
  • 31. Split and Flow DefiniYon <split id="mySplit"> <flow id="flow1"> <step id="myChunk" next="myBatchlet”>…</step> <step id="myBatchlet">...</step> </flow> <flow id="flow2"> <step id=”otherChunk" next=”otherBatchlet”>…</step> <step id=”otherBatchlet">...</step> </flow> </split>
  • 32. ParYYon vs Split • ParHHon is used at the data level • Split is used at the business level
  • 33. Decision • Decide the next TransiHon • Applied to Steps, Flows and Splits • It’s almost like an if / else if • Requires an implementaHon
  • 34. Decision DefiniYon <step id=”myStep" next="myDecider"> <batchlet ref="myBatchlet”/> </step> <decision id="myDecider" ref="MyDecider"> <next on="foo" to="myFooStep"/> <next on="bar" to="myBarStep"/> </decision>
  • 35. Decision @Named public class MyDecider implements Decider { public String decide(StepExecuYon[] execuYons) throws ExcepYon {…} }
  • 36. TransiYons • TransiHon Elements define the Workflow • Applied to Steps, Flows and Decision • Next, Fail, End, Stop • Fail, End and Stop terminate a Job
  • 37. Batch Exit Status • A Job and Steps has an Exit Status • Used to control the Workflow • STARTING, STARTED, STOPPING, STOPPED, FAILED, COMPLETED, ABANDONED
  • 38. Schedule a Job (By @Schedule) @Singleton public class BatchJobRunner { @Schedule(dayOfWeek = "Sun") public void scheduleJob() { JobOperator jobOperator = BatchRunYme.getJobOperator(); jobOperator.start("myJob", new ProperYes()); } }
  • 39. Schedule a Job (By ManagedScheduledExecutorService) @Resource(lookup="java:comp/DefaultManagedScheduledExecutorService") private ManagedScheduledExecutorService executor; public void scheduleJob() { JobOperator jobOperator = BatchRunYme.getJobOperator(); executor.schedule( () -­‐> jobOperator.start("myJob", new ProperYes()), 7, TimeUnit.DAYS); }
  • 40. ImplementaYons • JBatch IBM (Glassfish, JEUS) • JBeret (Wildfly) • Spring Batch
  • 41. A Few Cons • Lacks standard Readers / Writers • No Generics • ParHHon only supports a single Step • No Sync mode
  • 43. WoW AucYon House • World of WacraT is MMORPG • More than 500 servers in US and EU • Each server has 2 AucHon Houses • Trades around 70k items / server / hour
  • 44. WoW AucYon House • Data available to download • Let’s process the data • Extract metrics • Share the knowledge
  • 46. Resources • JSR-­‐352 SpecificaHon hips://jcp.org/en/jsr/detail?id=352 • Java EE Samples hips://github.com/javaee-­‐samples • Wow AucHon House hips://github.com/radcortez/wow-­‐aucHons
  • 47. Thank you for A/ending! Roberto Cortez @radcortez h/p://www.radcortez.com Ivan St. Ivanov @ivan_stefanov h/p://nosoGskills.com