Slide 1

Slide 1 text

Batch - JavaLand 2014 @ivar_grimstad Implementing Batch Processing in Java EE 7 Ivar Grimstad

Slide 2

Slide 2 text

Ivar Grimstad About Batch - JavaLand 2014 @ivar_grimstad @ivar_grimstad

Slide 3

Slide 3 text

batch (plural batches) The quantity of bread or other baked goods baked at one time. We made a batch of cookies to take to the party. Batch - JavaLand 2014 @ivar_grimstad Source: http://en.wiktionary.org/wiki/batch

Slide 4

Slide 4 text

Batch Applications Batch in Java EE 7 Demo Wrap-Up Content Batch - JavaLand 2014 @ivar_grimstad

Slide 5

Slide 5 text

History Batch - JavaLand 2014 @ivar_grimstad

Slide 6

Slide 6 text

Batch Applications Batch - JavaLand 2014 @ivar_grimstad

Slide 7

Slide 7 text

Bulk database updates Image processing Conversions Common Usages Batch - JavaLand 2014 @ivar_grimstad

Slide 8

Slide 8 text

No User Interaction Utilize Batch Windows Repetitive Work Advantages of Batch Processing Batch - JavaLand 2014 @ivar_grimstad

Slide 9

Slide 9 text

Training Difficult Debugging Costly Disadvantages of Batch Processing Batch - JavaLand 2014 @ivar_grimstad

Slide 10

Slide 10 text

Batch Frameworks To The Rescue Batch - JavaLand 2014 @ivar_grimstad

Slide 11

Slide 11 text

Jobs, steps, decision elements, relationships Parallel or sequential processing State Launch, pause and resume Error handling Batch Frameworks Batch - JavaLand 2014 @ivar_grimstad

Slide 12

Slide 12 text

Large Data Volume Automation Robustness Reliability Performance Requirements of Batch Applications Batch - JavaLand 2014 @ivar_grimstad

Slide 13

Slide 13 text

Batch - JavaLand 2014 @ivar_grimstad Batch Processing in Java EE 7

Slide 14

Slide 14 text

Batch Runtime Job Specification Java API – Runtime interaction – Implementation The Batch Processing Framework Batch - JavaLand 2014 @ivar_grimstad

Slide 15

Slide 15 text

Start jobs Check status of jobs Batch Runtime Batch - JavaLand 2014 @ivar_grimstad

Slide 16

Slide 16 text

Steps Flows Splits Decision Elements Job Specification Batch - JavaLand 2014 @ivar_grimstad

Slide 17

Slide 17 text

Job Specification Language (JSL) Batch - JavaLand 2014 @ivar_grimstad ... ... ... ... ...

Slide 18

Slide 18 text

Java Batch API (task oriented) Batch - JavaLand 2014 @ivar_grimstad Package Interface Description javax.batch.api Batchlet Implements the business logic of a task-oriented step.

Slide 19

Slide 19 text

Java Batch API (chunk oriented) Batch - JavaLand 2014 @ivar_grimstad Package Interface Description javax.batch.api.chunk ItemReader Reads items from an input source in a chunk step. javax.batch.api.chunk ItemProcessor Processes input items to obtain output items in chunk steps. javax.batch.api.chunk ItemWriter Writes output items in chunk steps.

Slide 20

Slide 20 text

ItemReader ItemWriter ItemProcessor Chunk Oriented Steps Batch - JavaLand 2014 @ivar_grimstad Item Item

Slide 21

Slide 21 text

Dependency Injection Batch - JavaLand 2014 @ivar_grimstad @Dependent @Named("MyItemReader") public class MyItemReaderImpl implements ItemReader { } ...

Slide 22

Slide 22 text

Batch Runtime API Batch - JavaLand 2014 @ivar_grimstad @Dependent @Named("MyItemReader") public class MyItemReaderImpl implements ItemReader { @Inject JobContext jobCtx; @Inject StepContext stepCtx; }

Slide 23

Slide 23 text

Invocation Batch - JavaLand 2014 @ivar_grimstad jobOperator = BatchRuntime.getJobOperator(); Properties props = new Properties(); props.setProperty("parameter1", "value1"); long execID = jobOperator.start("simplejob", props); EJB, Servlet, ManagedBean etc.

Slide 24

Slide 24 text

No separate packaging needed Can be included in any Java EE application – META-INF/batch-jobs/ – WEB-INF/classes/META-INF/batch-jobs/ Packaging Batch - JavaLand 2014 @ivar_grimstad

Slide 25

Slide 25 text

Monitoring Batch - JavaLand 2014 @ivar_grimstad Package Interface Description javax.batch.runtime JobExecution Provides methods to obtain information about submitted jobs. JobExecution jobExec = jobOperator.getJobExection(id); String status = jobExec.getBatchStatus().toString();

Slide 26

Slide 26 text

Design the application Create batch artifacts Define jobs, steps and execution flow Launch batch application Creating a Java EE Batch Application Batch - JavaLand 2014 @ivar_grimstad

Slide 27

Slide 27 text

Batch - JavaLand 2014 @ivar_grimstad DEMO

Slide 28

Slide 28 text

Create a simple batchlet Create a simple chunk oriented job Package in a WAR Start jobs from a Servlet Schedule jobs from Timer EJB Demo Steps Batch - JavaLand 2014 @ivar_grimstad

Slide 29

Slide 29 text

Simple Batchlet Batch - JavaLand 2014 @ivar_grimstad

Slide 30

Slide 30 text

Simple Chunk Oriented Batch - JavaLand 2014 @ivar_grimstad

Slide 31

Slide 31 text

Created a simple batchlet Created a simple chunk oriented job Packaged application in a WAR Started jobs from a Servlet Scheduled jobs from Timer EJB Demo Steps (what we did) Batch - JavaLand 2014 @ivar_grimstad

Slide 32

Slide 32 text

Batch - JavaLand 2014 @ivar_grimstad Summary

Slide 33

Slide 33 text

…but isn’t it? Batch - JavaLand 2014 @ivar_grimstad

Slide 34

Slide 34 text

Simple and Flexible Clear and precise API No separate packaging required Is a part of Java EE Summary Batch - JavaLand 2014 @ivar_grimstad

Slide 35

Slide 35 text

https://github.com/ivargrimstad/javaee-batch https://github.com/javaee-samples/javaee7-samples Sources Batch - JavaLand 2014 @ivar_grimstad

Slide 36

Slide 36 text

Batch - JavaLand 2014 @ivar_grimstad