Class RemoteChunkingManagerStepBuilder<I,O>
java.lang.Object
org.springframework.batch.core.step.builder.StepBuilderHelper<AbstractTaskletStepBuilder<B>>
org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder<SimpleStepBuilder<I,O>>
org.springframework.batch.core.step.builder.SimpleStepBuilder<I,O>
org.springframework.batch.core.step.builder.FaultTolerantStepBuilder<I,O>
org.springframework.batch.integration.chunk.RemoteChunkingManagerStepBuilder<I,O>
- Type Parameters:
I
- type of input itemsO
- type of output items
Builder for a manager step in a remote chunking setup. This builder creates and
sets a
ChunkMessageChannelItemWriter
on the manager step.
If no messagingTemplate
is provided through
messagingTemplate(MessagingTemplate)
,
this builder will create one and set its default channel to the outputChannel
provided through outputChannel(MessageChannel)
.
If a messagingTemplate
is provided, it is assumed that it is fully configured
and that its default channel is set to an output channel on which requests to workers
will be sent.
- Since:
- 4.2
- Author:
- Mahmoud Ben Hassine
-
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
ConstructorDescriptionRemoteChunkingManagerStepBuilder
(String stepName) Create a newRemoteChunkingManagerStepBuilder
. -
Method Summary
Modifier and TypeMethodDescriptionallowStartIfComplete
(boolean allowStartIfComplete) backOffPolicy
(org.springframework.retry.backoff.BackOffPolicy backOffPolicy) Provide a backoff policy to prevent items being retried immediately (e.g.build()
Build a managerTaskletStep
.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.exceptionHandler
(ExceptionHandler exceptionHandler) Sets the exception handler to use in the case of tasklet failures.inputChannel
(org.springframework.messaging.PollableChannel inputChannel) Set the input channel on which replies from workers will be received.keyGenerator
(KeyGenerator keyGenerator) Sets the key generator for identifying retried items.Registers objects using the annotation based listener configuration.listener
(ChunkListener listener) Register a chunk listener.listener
(ItemReadListener<? super I> listener) Register an item reader listener.listener
(ItemWriteListener<? super O> listener) Register an item writer listener.listener
(SkipListener<? super I, ? super O> listener) Register a skip listener.listener
(StepExecutionListener listener) listener
(org.springframework.retry.RetryListener listener) Register a retry listener.maxWaitTimeouts
(int maxWaitTimeouts) The maximum number of times to wait at the end of a step for a non-null result from the remote workers.messagingTemplate
(org.springframework.integration.core.MessagingTemplate messagingTemplate) Set theMessagingTemplate
to use to send data to workers.Explicitly ask for an exception (and subclasses) to be excluded from retry.noRollback
(Class<? extends Throwable> type) Mark this exception as ignorable during item read or processing operations.Explicitly prevent certain exceptions (and subclasses) from being skipped.outputChannel
(org.springframework.messaging.MessageChannel outputChannel) Set the output channel on which requests to workers will be sent.processor
(ItemProcessor<? super I, ? extends O> itemProcessor) 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.repository
(JobRepository jobRepository) Explicitly ask for an exception (and subclasses) to be retried.retryContextCache
(org.springframework.retry.policy.RetryContextCache retryContextCache) Provide an explicit retry context cache.retryLimit
(int retryLimit) The maximum number of times to try a failed item.retryPolicy
(org.springframework.retry.RetryPolicy retryPolicy) Provide an explicit retry policy instead of using theFaultTolerantStepBuilder.retryLimit(int)
and retryable exceptions provided elsewhere.Explicitly request certain exceptions (and subclasses) to be skipped.skipLimit
(int skipLimit) Sets the maximum number of failed items to skip before the step fails.skipPolicy
(SkipPolicy skipPolicy) Provide an explicit policy for managing skips.startLimit
(int startLimit) stepOperations
(RepeatOperations repeatTemplate) Sets the repeat template used for iterating the tasklet execution.stream
(ItemStream stream) Register a stream for callbacks that manage restart data.throttleLimit
(long throttleLimit) Public setter for the throttle limit.transactionAttribute
(org.springframework.transaction.interceptor.TransactionAttribute transactionAttribute) Sets the transaction attributes for the tasklet execution.transactionManager
(org.springframework.transaction.PlatformTransactionManager transactionManager) writer
(ItemWriter<? super O> writer) This method will throw aUnsupportedOperationException
since the item writer of the manager step in a remote chunking setup will be automatically set to an instance ofChunkMessageChannelItemWriter
.Methods inherited from class org.springframework.batch.core.step.builder.FaultTolerantStepBuilder
createChunkProcessor, createChunkProvider, createRetryOperations, createSkipPolicy, createTasklet, detectStreamInReader, faultTolerant, getChunkMonitor, getFatalExceptionAwareProxy, getRollbackClassifier, getSkipListeners, processorNonTransactional, registerStepListenerAsSkipListener
Methods inherited from class org.springframework.batch.core.step.builder.SimpleStepBuilder
createChunkOperations, getChunkCompletionPolicy, getChunkSize, getItemListeners, getProcessor, getReader, getWriter, isReaderTransactionalQueue, listener, registerAsStreamsAndListeners, registerStepListenerAsItemListener
Methods inherited from class org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder
concurrent, getExceptionHandler, getStepOperations, getStreams, getTaskExecutor, getThrottleLimit, getTransactionAttribute, registerStepListenerAsChunkListener, taskExecutor, throttleLimit
Methods inherited from class org.springframework.batch.core.step.builder.StepBuilderHelper
enhance, getJobRepository, getName, getTransactionManager, isAllowStartIfComplete
-
Constructor Details
-
RemoteChunkingManagerStepBuilder
Create a newRemoteChunkingManagerStepBuilder
.- Parameters:
stepName
- name of the manager step
-
-
Method Details
-
inputChannel
public RemoteChunkingManagerStepBuilder<I,O> inputChannel(org.springframework.messaging.PollableChannel inputChannel) Set the input channel on which replies from workers will be received. The provided input channel will be set as a reply channel on theChunkMessageChannelItemWriter
created by this builder.- Parameters:
inputChannel
- the input channel- Returns:
- this builder instance for fluent chaining
- See Also:
-
outputChannel
public RemoteChunkingManagerStepBuilder<I,O> outputChannel(org.springframework.messaging.MessageChannel outputChannel) Set the output channel on which requests to workers will be sent. By using this setter, a default messaging template will be created and the output channel will be set as its default channel.Use either this setter or
messagingTemplate(MessagingTemplate)
to provide a fully configured messaging template.- Parameters:
outputChannel
- the output channel.- Returns:
- this builder instance for fluent chaining
- See Also:
-
messagingTemplate
public RemoteChunkingManagerStepBuilder<I,O> messagingTemplate(org.springframework.integration.core.MessagingTemplate messagingTemplate) Set theMessagingTemplate
to use to send data to workers. The default channel of the messaging template must be set.Use either this setter to provide a fully configured messaging template or provide an output channel through
outputChannel(MessageChannel)
and a default messaging template will be created.- Parameters:
messagingTemplate
- the messaging template to use- Returns:
- this builder instance for fluent chaining
- See Also:
-
maxWaitTimeouts
The maximum number of times to wait at the end of a step for a non-null result from the remote workers. This is a multiplier on the receive timeout set separately on the gateway. The ideal value is a compromise between allowing slow workers time to finish, and responsiveness if there is a dead worker. Defaults to 40.- Parameters:
maxWaitTimeouts
- the maximum number of wait timeouts- Returns:
- this builder instance for fluent chaining
- See Also:
-
throttleLimit
Public setter for the throttle limit. This limits the number of pending requests for chunk processing to avoid overwhelming the receivers.- Parameters:
throttleLimit
- the throttle limit to set- Returns:
- this builder instance for fluent chaining
- See Also:
-
build
Build a managerTaskletStep
.- Overrides:
build
in classFaultTolerantStepBuilder<I,
O> - Returns:
- the configured manager step
- See Also:
-
reader
Description copied from class:SimpleStepBuilder
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.- Overrides:
reader
in classSimpleStepBuilder<I,
O> - Parameters:
reader
- an item reader- Returns:
- this for fluent chaining
- See Also:
-
SimpleStepBuilder.readerTransactionalQueue
-
repository
- Overrides:
repository
in classStepBuilderHelper<AbstractTaskletStepBuilder<SimpleStepBuilder<I,
O>>>
-
transactionManager
public RemoteChunkingManagerStepBuilder<I,O> transactionManager(org.springframework.transaction.PlatformTransactionManager transactionManager) - Overrides:
transactionManager
in classStepBuilderHelper<AbstractTaskletStepBuilder<SimpleStepBuilder<I,
O>>>
-
listener
Description copied from class:FaultTolerantStepBuilder
Registers objects using the annotation based listener configuration.- Overrides:
listener
in classFaultTolerantStepBuilder<I,
O> - Parameters:
listener
- the object that has a method configured with listener annotation- Returns:
- this for fluent chaining
-
listener
Description copied from class:FaultTolerantStepBuilder
Register a skip listener.- Overrides:
listener
in classFaultTolerantStepBuilder<I,
O> - Parameters:
listener
- the listener to register- Returns:
- this for fluent chaining
-
listener
Description copied from class:AbstractTaskletStepBuilder
Register a chunk listener.- Overrides:
listener
in classFaultTolerantStepBuilder<I,
O> - Parameters:
listener
- the listener to register- Returns:
- this for fluent chaining
-
transactionAttribute
public RemoteChunkingManagerStepBuilder<I,O> transactionAttribute(org.springframework.transaction.interceptor.TransactionAttribute transactionAttribute) Description copied from class:AbstractTaskletStepBuilder
Sets the transaction attributes for the tasklet execution. Defaults to the default values for the transaction manager, but can be manipulated to provide longer timeouts for instance.- Overrides:
transactionAttribute
in classFaultTolerantStepBuilder<I,
O> - Parameters:
transactionAttribute
- a transaction attribute set- Returns:
- this for fluent chaining
-
listener
public RemoteChunkingManagerStepBuilder<I,O> listener(org.springframework.retry.RetryListener listener) Description copied from class:FaultTolerantStepBuilder
Register a retry listener.- Overrides:
listener
in classFaultTolerantStepBuilder<I,
O> - Parameters:
listener
- the listener to register- Returns:
- this for fluent chaining
-
keyGenerator
Description copied from class:FaultTolerantStepBuilder
Sets the key generator for identifying retried items. Retry across transaction boundaries requires items to be identified when they are encountered again. The default strategy is to use the items themselves, relying on their own implementation to ensure that they can be identified. Often a key generator is not necessary as long as the items have reliable hash code and equals implementations, or the reader is not transactional (the default) and the item processor either is itself not transactional (not the default) or does not create new items.- Overrides:
keyGenerator
in classFaultTolerantStepBuilder<I,
O> - Parameters:
keyGenerator
- a key generator for the stateful retry- Returns:
- this for fluent chaining
-
retryLimit
Description copied from class:FaultTolerantStepBuilder
The maximum number of times to try a failed item. Zero and one both translate to try only once and do not retry. Ignored if an explicitFaultTolerantStepBuilder.retryPolicy
is set.- Overrides:
retryLimit
in classFaultTolerantStepBuilder<I,
O> - Parameters:
retryLimit
- the retry limit (default 0)- Returns:
- this for fluent chaining
-
retryPolicy
public RemoteChunkingManagerStepBuilder<I,O> retryPolicy(org.springframework.retry.RetryPolicy retryPolicy) Description copied from class:FaultTolerantStepBuilder
Provide an explicit retry policy instead of using theFaultTolerantStepBuilder.retryLimit(int)
and retryable exceptions provided elsewhere. Can be used to retry different exceptions a different number of times, for instance.- Overrides:
retryPolicy
in classFaultTolerantStepBuilder<I,
O> - Parameters:
retryPolicy
- a retry policy- Returns:
- this for fluent chaining
-
backOffPolicy
public RemoteChunkingManagerStepBuilder<I,O> backOffPolicy(org.springframework.retry.backoff.BackOffPolicy backOffPolicy) Description copied from class:FaultTolerantStepBuilder
Provide a backoff policy to prevent items being retried immediately (e.g. in case the failure was caused by a remote resource failure that might take some time to be resolved). Ignored if an explicitFaultTolerantStepBuilder.retryPolicy
is set.- Overrides:
backOffPolicy
in classFaultTolerantStepBuilder<I,
O> - Parameters:
backOffPolicy
- the back off policy to use (default no backoff)- Returns:
- this for fluent chaining
-
retryContextCache
public RemoteChunkingManagerStepBuilder<I,O> retryContextCache(org.springframework.retry.policy.RetryContextCache retryContextCache) Description copied from class:FaultTolerantStepBuilder
Provide an explicit retry context cache. Retry is stateful across transactions in the case of failures in item processing or writing, so some information about the context for subsequent retries has to be stored.- Overrides:
retryContextCache
in classFaultTolerantStepBuilder<I,
O> - Parameters:
retryContextCache
- cache for retry contexts in between transactions (default to standard in-memory implementation)- Returns:
- this for fluent chaining
-
skipLimit
Description copied from class:FaultTolerantStepBuilder
Sets the maximum number of failed items to skip before the step fails. Ignored if an explicitFaultTolerantStepBuilder.skipPolicy(SkipPolicy)
is provided.- Overrides:
skipLimit
in classFaultTolerantStepBuilder<I,
O> - Parameters:
skipLimit
- the skip limit to set- Returns:
- this for fluent chaining
-
noSkip
Description copied from class:FaultTolerantStepBuilder
Explicitly prevent certain exceptions (and subclasses) from being skipped.- Overrides:
noSkip
in classFaultTolerantStepBuilder<I,
O> - Parameters:
type
- the non-skippable exception- Returns:
- this for fluent chaining
-
skip
Description copied from class:FaultTolerantStepBuilder
Explicitly request certain exceptions (and subclasses) to be skipped. These exceptions (and their subclasses) might be thrown during any phase of the chunk processing (read, process, write) but separate counts are made of skips on read, process and write inside the step execution.- Overrides:
skip
in classFaultTolerantStepBuilder<I,
O> - Parameters:
type
- the exception type.- Returns:
- this for fluent chaining
-
skipPolicy
Description copied from class:FaultTolerantStepBuilder
Provide an explicit policy for managing skips. A skip policy determines which exceptions are skippable and how many times.- Overrides:
skipPolicy
in classFaultTolerantStepBuilder<I,
O> - Parameters:
skipPolicy
- the skip policy- Returns:
- this for fluent chaining
-
noRollback
Description copied from class:FaultTolerantStepBuilder
Mark this exception as ignorable during item read or processing operations. Processing continues with no additional callbacks (use skips instead if you need to be notified). Ignored during write because there is no guarantee of skip and retry without rollback.- Overrides:
noRollback
in classFaultTolerantStepBuilder<I,
O> - Parameters:
type
- the exception to mark as no rollback- Returns:
- this for fluent chaining
-
noRetry
Description copied from class:FaultTolerantStepBuilder
Explicitly ask for an exception (and subclasses) to be excluded from retry.- Overrides:
noRetry
in classFaultTolerantStepBuilder<I,
O> - Parameters:
type
- the exception to exclude from retry- Returns:
- this for fluent chaining
-
retry
Description copied from class:FaultTolerantStepBuilder
Explicitly ask for an exception (and subclasses) to be retried.- Overrides:
retry
in classFaultTolerantStepBuilder<I,
O> - Parameters:
type
- the exception to retry- Returns:
- this for fluent chaining
-
stream
Description copied from class:AbstractTaskletStepBuilder
Register a stream for callbacks that manage restart data.- Overrides:
stream
in classFaultTolerantStepBuilder<I,
O> - Parameters:
stream
- the stream to register- Returns:
- this for fluent chaining
-
chunk
Description copied from class:SimpleStepBuilder
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 withSimpleStepBuilder.completionPolicy
.- Overrides:
chunk
in classSimpleStepBuilder<I,
O> - Parameters:
chunkSize
- the chunk size (a.k.a commit interval)- Returns:
- this for fluent chaining
-
chunk
Description copied from class:SimpleStepBuilder
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).- Overrides:
chunk
in classSimpleStepBuilder<I,
O> - Parameters:
completionPolicy
- a completion policy for the chunk- Returns:
- this for fluent chaining
-
writer
public RemoteChunkingManagerStepBuilder<I,O> writer(ItemWriter<? super O> writer) throws UnsupportedOperationException This method will throw aUnsupportedOperationException
since the item writer of the manager step in a remote chunking setup will be automatically set to an instance ofChunkMessageChannelItemWriter
. When building a manager step for remote chunking, no item writer must be provided.- Overrides:
writer
in classSimpleStepBuilder<I,
O> - Parameters:
writer
- an item writer- Returns:
- this for fluent chaining
- Throws:
UnsupportedOperationException
- if an item writer is provided- See Also:
-
readerIsTransactionalQueue
Description copied from class:SimpleStepBuilder
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.- Overrides:
readerIsTransactionalQueue
in classSimpleStepBuilder<I,
O> - Returns:
- this for fluent chaining
-
listener
Description copied from class:SimpleStepBuilder
Register an item reader listener.- Overrides:
listener
in classSimpleStepBuilder<I,
O> - Parameters:
listener
- the listener to register- Returns:
- this for fluent chaining
-
listener
Description copied from class:SimpleStepBuilder
Register an item writer listener.- Overrides:
listener
in classSimpleStepBuilder<I,
O> - Parameters:
listener
- the listener to register- Returns:
- this for fluent chaining
-
chunkOperations
Description copied from class:SimpleStepBuilder
Instead of achunk size
orcompletion policy
you can provide a complete repeat operations instance that handles the iteration over the item reader.- Overrides:
chunkOperations
in classSimpleStepBuilder<I,
O> - Parameters:
repeatTemplate
- a complete repeat template for the chunk- Returns:
- this for fluent chaining
-
exceptionHandler
Description copied from class:AbstractTaskletStepBuilder
Sets the exception handler to use in the case of tasklet failures. Default is to rethrow everything.- Overrides:
exceptionHandler
in classAbstractTaskletStepBuilder<SimpleStepBuilder<I,
O>> - Parameters:
exceptionHandler
- the exception handler- Returns:
- this for fluent chaining
-
stepOperations
Description copied from class:AbstractTaskletStepBuilder
Sets the repeat template used for iterating the tasklet execution. By default it will terminate only when the tasklet returns FINISHED (or null).- Overrides:
stepOperations
in classAbstractTaskletStepBuilder<SimpleStepBuilder<I,
O>> - Parameters:
repeatTemplate
- a repeat template with rules for iterating- Returns:
- this for fluent chaining
-
startLimit
- Overrides:
startLimit
in classStepBuilderHelper<AbstractTaskletStepBuilder<SimpleStepBuilder<I,
O>>>
-
listener
- Overrides:
listener
in classStepBuilderHelper<AbstractTaskletStepBuilder<SimpleStepBuilder<I,
O>>>
-
allowStartIfComplete
- Overrides:
allowStartIfComplete
in classStepBuilderHelper<AbstractTaskletStepBuilder<SimpleStepBuilder<I,
O>>>
-
processor
public RemoteChunkingManagerStepBuilder<I,O> processor(ItemProcessor<? super I, ? extends O> itemProcessor) Description copied from class:SimpleStepBuilder
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.- Overrides:
processor
in classSimpleStepBuilder<I,
O> - Parameters:
itemProcessor
- an item processor- Returns:
- this for fluent chaining
-