batch processing

69
Batch Processing ORA/J

Upload: ken-coenen

Post on 13-Apr-2017

385 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Batch processing

Batch ProcessingORA/J

Page 2: Batch processing

Agenda

Page 3: Batch processing

Batch principles

Page 4: Batch processing

Characteristics

Page 5: Batch processing

Batch processing ≠ Scheduling

Batch processing Scheduling

Process large volumes of data Scheduling tasks

eg. Spring Batch, JEE eg. Quartz, Obsidian

Page 6: Batch processing

Things to consider

▪▪

Page 7: Batch processing

Essential building blocks

Page 8: Batch processing

Categorize based on responsibility

Page 9: Batch processing

Categorize based on input source

Page 10: Batch processing

Guidelines

Page 11: Batch processing

Transaction Management

Page 12: Batch processing

ACID principle

Page 13: Batch processing

Transactions are handled at the step level

Page 14: Batch processing

Transaction management in steps (tasklets)

Step 1

Step 2

Step 3

Transaction

Transaction

Transaction x nn

Page 15: Batch processing

Example: chunk-oriented step

<step id="importProductsStep"> <tasklet> <chunk reader="reader" writer="writer" commit-interval="100" /> <transaction-attributes isolation="READ_UNCOMMITTED" /> </tasklet> </step>

Transaction

Page 16: Batch processing

Transaction management in listeners

▪ ChunkListener

beforeChunk afterChunk

Page 17: Batch processing

Transactional reader

<step id="importProductsStep"> <tasklet> <chunk reader="reader" writer="writer" commit-interval="100" reader-transactional-queue="true"/> <transaction-attributes isolation="READ_UNCOMMITTED" /> </tasklet></step>

Page 18: Batch processing

Transaction management patterns

Page 19: Batch processing

Transaction management patterns

Page 20: Batch processing

Transaction management patterns

▪ …

Page 21: Batch processing

Global transactions implementation

Page 22: Batch processing

Drawbacks to global transactions

▪▪

▪▪

Page 23: Batch processing

Shared resource transaction pattern

Page 24: Batch processing

Best effort pattern with JMS

Page 25: Batch processing

What can go wrong with JMS?

Page 26: Batch processing

Best effort pattern with JMS

comm

it

star

t

com

mit

start

Chunk localtransaction

JMS localtransaction

timeline

Commits are synchronized

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory" ref="connectionFactory" /> <property name="defaultDestination" ref="orderQueue" /> <property name="receiveTimeout" value="100" /> <property name="sessionTransacted" value="true" /></bean>

Page 27: Batch processing

JMS failure will result in a duplicate message

comm

it

star

t

com

mit

start

Chunk localtransaction

JMS localtransaction

timeline

Commits are synchronized

failed

Page 28: Batch processing

Handling duplicate messages with manual detection

Page 29: Batch processing

Handling duplicate messages with manual detection

Page 30: Batch processing

Handling duplicate messages with idempotency

Page 31: Batch processing

Conclusions

Page 32: Batch processing

Execution flows

Page 33: Batch processing

Execution flows

Page 34: Batch processing

Standard flow

Page 35: Batch processing

Conditional flow - example

Page 36: Batch processing

Conditional flow

Page 37: Batch processing

Conditional flow

Page 38: Batch processing

ExitStatus vs BatchStatus

Page 39: Batch processing

Custom Exitstatus

Page 40: Batch processing

Custom Batchstatus

▪▪▪

Page 41: Batch processing

Custom Batchstatus

Page 42: Batch processing

Parallel execution

Page 43: Batch processing

Parallel execution - types

Page 44: Batch processing

Parallel execution - Multithreaded

Page 45: Batch processing

Parallel execution - Remote chunking

Page 46: Batch processing

Parallel execution - Step partitioning

Page 47: Batch processing

Parallel execution - Step partitioning

Page 48: Batch processing

Parallel execution - Step partitioning example

Page 49: Batch processing

Demo: Speeder problem

Page 50: Batch processing

Introduction

Page 51: Batch processing

Introduction

Page 52: Batch processing

Introduction

▪▪▪▪▪

Page 53: Batch processing

Generating input

Page 54: Batch processing

Reading the input

Page 55: Batch processing

Reading the input

▪▪

Page 56: Batch processing

Processing the data

Page 57: Batch processing

Processing the lines we just read

▪ KmPerHourCalculator

▪ null

Page 58: Batch processing

Writing the data

Page 59: Batch processing

Writing the Fines

▪ BeanWrapperFieldExtractor

DelimitedLineAggregator

Page 60: Batch processing

Adding it all together

▪ BatchConfiguration

▪▪

▪ Step

Page 61: Batch processing

Listening in

○○○

Page 62: Batch processing

Gathering statistics

▪ StepExecutionContext

JobExecutionContext

Page 63: Batch processing

Gathering Statistics

Page 64: Batch processing

Spring Batch and JEE

Page 65: Batch processing

JSR-352

Page 66: Batch processing

JSR-352 Enterprise

Page 67: Batch processing

JSR-352 spring

Page 68: Batch processing

org.springframework.batch.core.

SkipListener#onSkipInWrite(S item, Throwable t)

javax.batch.api.chunk.listener.

SkipWriteListener#onSkipWriteItem(List<Object> items,

Exception ex)

JSR-352 Spring vs. JEE

Page 69: Batch processing

Questions?