Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Implementing Batch Processing in Java EE 7

Implementing Batch Processing in Java EE 7

Slides from my presentation at JavaLand 2014.

ivargrimstad

March 25, 2014
Tweet

More Decks by ivargrimstad

Other Decks in Programming

Transcript

  1. 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
  2. Batch Applications Batch in Java EE 7 Demo Wrap-Up Content

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

    Batch Processing Batch - JavaLand 2014 @ivar_grimstad
  4. Jobs, steps, decision elements, relationships Parallel or sequential processing State

    Launch, pause and resume Error handling Batch Frameworks Batch - JavaLand 2014 @ivar_grimstad
  5. Batch Runtime Job Specification Java API – Runtime interaction –

    Implementation The Batch Processing Framework Batch - JavaLand 2014 @ivar_grimstad
  6. Job Specification Language (JSL) Batch - JavaLand 2014 @ivar_grimstad <job>

    <listeners> <listener /> </listeners> <properties> <property /> </properties> <step ...> ... </step> <step ...> ... </step> <decision ...> ... </decision> <flow ...> ... </flow> <split ...> ... </split> </job>
  7. 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.
  8. 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.
  9. Dependency Injection Batch - JavaLand 2014 @ivar_grimstad @Dependent @Named("MyItemReader") public

    class MyItemReaderImpl implements ItemReader { } <step id="stepA" next="stepB"> <chunk> <reader ref="MyItemReader"></reader> ... </chunk> </step>
  10. Batch Runtime API Batch - JavaLand 2014 @ivar_grimstad @Dependent @Named("MyItemReader")

    public class MyItemReaderImpl implements ItemReader { @Inject JobContext jobCtx; @Inject StepContext stepCtx; }
  11. 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.
  12. 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
  13. 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();
  14. 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
  15. 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
  16. 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
  17. Simple and Flexible Clear and precise API No separate packaging

    required Is a part of Java EE Summary Batch - JavaLand 2014 @ivar_grimstad