Class SimpleStepBuilder<I,O>
java.lang.Object
org.springframework.batch.core.step.builder.StepBuilderHelper<B>
org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder<SimpleStepBuilder<I,O>>
org.springframework.batch.core.step.builder.SimpleStepBuilder<I,O>
- Direct Known Subclasses:
FaultTolerantStepBuilder
Step builder for simple item processing (chunk oriented) steps. Items are read and
cached in chunks, and then processed (transformed) and written (optionally the
processor can be omitted) all in the same transaction.
- Since:
- 2.2
- Author:
- Dave Syer, Mahmoud Ben Hassine, Parikshit Dutta
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper
StepBuilderHelper.CommonStepProperties
-
Field Summary
Fields inherited from class org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder
chunkListeners
Fields inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper
logger, properties
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SimpleStepBuilder
(SimpleStepBuilder<I, O> parent) Create a new builder initialized with any properties in the parent.SimpleStepBuilder
(StepBuilderHelper<?> parent) Create a new builder initialized with any properties in the parent. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build a step with the reader, writer, processor as provided.chunk
(int chunkSize) Sets the chunk size or commit interval for this step.chunk
(CompletionPolicy completionPolicy) Sets a completion policy for the chunk processing.chunkOperations
(RepeatOperations repeatTemplate) Instead of achunk size
orcompletion policy
you can provide a complete repeat operations instance that handles the iteration over the item reader.protected RepeatOperations
protected Tasklet
protected CompletionPolicy
protected int
protected Set<StepListener>
protected ItemProcessor<? super I,
? extends O> protected ItemReader<? extends I>
protected ItemWriter<? super O>
protected boolean
Registers objects using the annotation based listener configuration.listener
(ItemProcessListener<? super I, ? super O> listener) Register an item processor listener.listener
(ItemReadListener<? super I> listener) Register an item reader listener.listener
(ItemWriteListener<? super O> listener) Register an item writer listener.processor
(ItemProcessor<? super I, ? extends O> processor) An item processor that processes or transforms a stream of items.reader
(ItemReader<? extends I> reader) An item reader that provides a stream of items.Sets a flag to say that the reader is transactional (usually a queue), which is to say that failed items might be rolled back and re-presented in a subsequent transaction.protected void
registerAsStreamsAndListeners
(ItemReader<? extends I> itemReader, ItemProcessor<? super I, ? extends O> itemProcessor, ItemWriter<? super O> itemWriter) protected void
protected SimpleStepBuilder<I,
O> self()
writer
(ItemWriter<? super O> writer) An item writer that writes a chunk of items.Methods inherited from class org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder
concurrent, exceptionHandler, getExceptionHandler, getStepOperations, getStreams, getTaskExecutor, getThrottleLimit, getTransactionAttribute, getTransactionManager, listener, registerStepListenerAsChunkListener, stepOperations, stream, taskExecutor, throttleLimit, transactionAttribute, transactionManager
Methods inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper
allowStartIfComplete, enhance, getJobRepository, getName, isAllowStartIfComplete, listener, meterRegistry, observationConvention, observationRegistry, repository, startLimit
-
Constructor Details
-
SimpleStepBuilder
Create a new builder initialized with any properties in the parent. The parent is copied, so it can be re-used.- Parameters:
parent
- a parent helper containing common step properties
-
SimpleStepBuilder
Create a new builder initialized with any properties in the parent. The parent is copied, so it can be re-used.- Parameters:
parent
- a parent helper containing common step properties
-
-
Method Details
-
faultTolerant
-
build
Build a step with the reader, writer, processor as provided.- Overrides:
build
in classAbstractTaskletStepBuilder<SimpleStepBuilder<I,
O>> - Returns:
- a tasklet step fully configured and ready to execute
- See Also:
-
registerStepListenerAsItemListener
protected void registerStepListenerAsItemListener() -
createTasklet
- Specified by:
createTasklet
in classAbstractTaskletStepBuilder<SimpleStepBuilder<I,
O>>
-
chunk
Sets the chunk size or commit interval for this step. This is the maximum number of items that will be read before processing starts in a single transaction. Not compatible withcompletionPolicy
.- Parameters:
chunkSize
- the chunk size (a.k.a commit interval)- Returns:
- this for fluent chaining
-
chunk
Sets a completion policy for the chunk processing. Items are read until this policy determines that a chunk is complete, giving more control than with just thechunk size
(or commit interval).- Parameters:
completionPolicy
- a completion policy for the chunk- Returns:
- this for fluent chaining
-
reader
An item reader that provides a stream of items. Will be automatically registered as aAbstractTaskletStepBuilder.stream(ItemStream)
or listener if it implements the corresponding interface. By default assumed to be non-transactional.- Parameters:
reader
- an item reader- Returns:
- this for fluent chaining
- See Also:
-
readerTransactionalQueue
-
writer
An item writer that writes a chunk of items. Will be automatically registered as aAbstractTaskletStepBuilder.stream(ItemStream)
or listener if it implements the corresponding interface.- Parameters:
writer
- an item writer- Returns:
- this for fluent chaining
-
processor
An item processor that processes or transforms a stream of items. Will be automatically registered as aAbstractTaskletStepBuilder.stream(ItemStream)
or listener if it implements the corresponding interface.- Parameters:
processor
- an item processor- Returns:
- this for fluent chaining
-
readerIsTransactionalQueue
Sets a flag to say that the reader is transactional (usually a queue), which is to say that failed items might be rolled back and re-presented in a subsequent transaction. Default is false, meaning that the items are read outside a transaction and possibly cached.- Returns:
- this for fluent chaining
-
listener
Registers objects using the annotation based listener configuration.- Overrides:
listener
in classAbstractTaskletStepBuilder<SimpleStepBuilder<I,
O>> - Parameters:
listener
- the object that has a method configured with listener annotation- Returns:
- this for fluent chaining
-
listener
Register an item reader listener.- Parameters:
listener
- the listener to register- Returns:
- this for fluent chaining
-
listener
Register an item writer listener.- Parameters:
listener
- the listener to register- Returns:
- this for fluent chaining
-
listener
Register an item processor listener.- Parameters:
listener
- the listener to register- Returns:
- this for fluent chaining
-
chunkOperations
Instead of achunk size
orcompletion policy
you can provide a complete repeat operations instance that handles the iteration over the item reader.- Parameters:
repeatTemplate
- a complete repeat template for the chunk- Returns:
- this for fluent chaining
-
self
- Specified by:
self
in classStepBuilderHelper<SimpleStepBuilder<I,
O>>
-
createChunkOperations
-
getReader
-
getWriter
-
getProcessor
-
getChunkSize
protected int getChunkSize() -
isReaderTransactionalQueue
protected boolean isReaderTransactionalQueue() -
getItemListeners
-
getChunkCompletionPolicy
- Returns:
- a
CompletionPolicy
consistent with the chunk size and injected policy (if present).
-
registerAsStreamsAndListeners
protected void registerAsStreamsAndListeners(ItemReader<? extends I> itemReader, ItemProcessor<? super I, ? extends O> itemProcessor, ItemWriter<? super O> itemWriter)
-