69
Batch Processing ORA/J

Batch Processing - A&BP CC

Embed Size (px)

Citation preview

Page 1: Batch Processing - A&BP CC

Batch ProcessingORA/J

Page 2: Batch Processing - A&BP CC

Agenda

Page 3: Batch Processing - A&BP CC

Batch principles

Page 4: Batch Processing - A&BP CC

Characteristics

Page 5: Batch Processing - A&BP CC

Batch processing ≠ Scheduling

Batch processing Scheduling

Process large volumes of data Scheduling tasks

eg. Spring Batch, JEE eg. Quartz, Obsidian

Page 6: Batch Processing - A&BP CC

Things to consider

▪▪

Page 7: Batch Processing - A&BP CC

Essential building blocks

Page 8: Batch Processing - A&BP CC

Categorize based on responsibility

Page 9: Batch Processing - A&BP CC

Categorize based on input source

Page 10: Batch Processing - A&BP CC

Guidelines

Page 11: Batch Processing - A&BP CC

Transaction Management

Page 12: Batch Processing - A&BP CC

ACID principle

Page 13: Batch Processing - A&BP CC

Transactions are handled at the step level

Page 14: Batch Processing - A&BP CC

Transaction management in steps (tasklets)

Step 1

Step 2

Step 3

Transaction

Transaction

Transaction x nn

Page 15: Batch Processing - A&BP CC

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 - A&BP CC

Transaction management in listeners

▪ ChunkListener

beforeChunk afterChunk

Page 17: Batch Processing - A&BP CC

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 - A&BP CC

Transaction management patterns

Page 19: Batch Processing - A&BP CC

Transaction management patterns

Page 20: Batch Processing - A&BP CC

Transaction management patterns

▪ …

Page 21: Batch Processing - A&BP CC

Global transactions implementation

Page 22: Batch Processing - A&BP CC

Drawbacks to global transactions

▪▪

▪▪

Page 23: Batch Processing - A&BP CC

Shared resource transaction pattern

Page 24: Batch Processing - A&BP CC

Best effort pattern with JMS

Page 25: Batch Processing - A&BP CC

What can go wrong with JMS?

Page 26: Batch Processing - A&BP CC

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 - A&BP CC

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 - A&BP CC

Handling duplicate messages with manual detection

Page 29: Batch Processing - A&BP CC

Handling duplicate messages with manual detection

Page 30: Batch Processing - A&BP CC

Handling duplicate messages with idempotency

Page 31: Batch Processing - A&BP CC

Conclusions

Page 32: Batch Processing - A&BP CC

Execution flows

Page 33: Batch Processing - A&BP CC

Execution flows

Page 34: Batch Processing - A&BP CC

Standard flow

Page 35: Batch Processing - A&BP CC

Conditional flow - example

Page 36: Batch Processing - A&BP CC

Conditional flow

Page 37: Batch Processing - A&BP CC

Conditional flow

Page 38: Batch Processing - A&BP CC

ExitStatus vs BatchStatus

Page 39: Batch Processing - A&BP CC

Custom Exitstatus

Page 40: Batch Processing - A&BP CC

Custom Batchstatus

▪▪▪

Page 41: Batch Processing - A&BP CC

Custom Batchstatus

Page 42: Batch Processing - A&BP CC

Parallel execution

Page 43: Batch Processing - A&BP CC

Parallel execution - types

Page 44: Batch Processing - A&BP CC

Parallel execution - Multithreaded

Page 45: Batch Processing - A&BP CC

Parallel execution - Remote chunking

Page 46: Batch Processing - A&BP CC

Parallel execution - Step partitioning

Page 47: Batch Processing - A&BP CC

Parallel execution - Step partitioning

Page 48: Batch Processing - A&BP CC

Parallel execution - Step partitioning example

Page 49: Batch Processing - A&BP CC

Demo: Speeder problem

Page 50: Batch Processing - A&BP CC

Introduction

Page 51: Batch Processing - A&BP CC

Introduction

Page 52: Batch Processing - A&BP CC

Introduction

▪▪▪▪▪

Page 53: Batch Processing - A&BP CC

Generating input

Page 54: Batch Processing - A&BP CC

Reading the input

Page 55: Batch Processing - A&BP CC

Reading the input

▪▪

Page 56: Batch Processing - A&BP CC

Processing the data

Page 57: Batch Processing - A&BP CC

Processing the lines we just read

▪ KmPerHourCalculator

▪ null

Page 58: Batch Processing - A&BP CC

Writing the data

Page 59: Batch Processing - A&BP CC

Writing the Fines

▪ BeanWrapperFieldExtractor

DelimitedLineAggregator

Page 60: Batch Processing - A&BP CC

Adding it all together

▪ BatchConfiguration

▪▪

▪ Step

Page 61: Batch Processing - A&BP CC

Listening in

○○○

Page 62: Batch Processing - A&BP CC

Gathering statistics

▪ StepExecutionContext

JobExecutionContext

Page 63: Batch Processing - A&BP CC

Gathering Statistics

Page 64: Batch Processing - A&BP CC

Spring Batch and JEE

Page 65: Batch Processing - A&BP CC

JSR-352

Page 66: Batch Processing - A&BP CC

JSR-352 Enterprise

Page 67: Batch Processing - A&BP CC

JSR-352 spring

Page 68: Batch Processing - A&BP CC

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 - A&BP CC

Questions?