This talk will explore one of the newest API for Java EE 7, the JSR 352, Batch Applications for the Java Platform. Batch processing is found in nearly every industry when you need to execute a non-interactive, bulk-oriented and long running operation task. A few examples are: financial transactions, billing, inventory management, report generation and so on. The JSR 352 specifies a common set of requirements that every batch application usually needs like: checkpointing, parallelization, splitting and logging. It also provides you with a job specification language and several interfaces that allow you to implement your business logic and interact with the batch container. We are going to live code a real life example batch application, starting with a simple task and then evolve it using the advanced API's until we have a full parallel and checkpointing reader-processor-writer batch. By the end of the session, attendees should be able to understand the use cases of the JSR 352, when to apply it and how to develop a full Java EE Batch Application.
2024: Domino Containers - The Next Step. News from the Domino Container commu...
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
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
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);
}
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