Class RemoteChunkingManagerBuilder
ChunkOrientedStep, whose item writer is a ChunkMessageChannelItemWriter
that sends chunks to remote workers and waits for their replies.
This builder holds the settings that are specific to remote chunking (the channels, the
messaging template, the maximum number of wait timeouts and the throttle limit). Once
those are set, calling chunk(int) returns a ChunkOrientedStepBuilder
on which everything else (reader, processor, transaction manager, listeners, retry and
skip policies, etc) is configured as for any other chunk-oriented step:
Step managerStep = new RemoteChunkingManagerBuilder("managerStep", jobRepository)
.outputChannel(requests)
.inputChannel(replies)
.<Integer, Integer> chunk(100)
.reader(itemReader)
.transactionManager(transactionManager)
.build();
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.
Please note that:
- The item writer of the step is set by this builder and must not be changed on the
ChunkOrientedStepBuilderreturned bychunk(int). - Only
chunk(int)configures a remote chunking manager step. Other methods inherited fromStepBuilderthat create steps are not meant to be used with this builder. - As for any
ChunkOrientedStepBuilder, the transaction manager defaults to a resourceless one. It should be set explicitly if the item reader of the manager step needs a transactional resource.
- Since:
- 6.1
- Author:
- Mahmoud Ben Hassine
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class StepBuilderHelper
StepBuilderHelper.CommonStepProperties -
Field Summary
Fields inherited from class StepBuilderHelper
logger, properties -
Constructor Summary
ConstructorsConstructorDescriptionRemoteChunkingManagerBuilder(String name, JobRepository jobRepository) Create a newRemoteChunkingManagerBuilder. -
Method Summary
Modifier and TypeMethodDescription<I,O> ChunkOrientedStepBuilder <I, O> chunk(int chunkSize) Create aChunkOrientedStepBuilderfor a manager step with the given chunk size.inputChannel(org.springframework.messaging.SubscribableChannel inputChannel) Set the input channel on which replies from workers will be received.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 theMessagingTemplateto use to send data to workers.outputChannel(org.springframework.messaging.MessageChannel outputChannel) Set the output channel on which requests to workers will be sent.throttleLimit(long throttleLimit) Set the throttle limit.Methods inherited from class StepBuilder
chunk, chunk, flow, job, partitioner, partitioner, self, tasklet, taskletMethods inherited from class StepBuilderHelper
allowStartIfComplete, enhance, getJobRepository, getName, isAllowStartIfComplete, listener, listener, observationRegistry, startLimit
-
Constructor Details
-
RemoteChunkingManagerBuilder
Create a newRemoteChunkingManagerBuilder.- Parameters:
name- name of the manager stepjobRepository- the job repository the step should report to
-
-
Method Details
-
inputChannel
public RemoteChunkingManagerBuilder inputChannel(org.springframework.messaging.SubscribableChannel 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 theChunkMessageChannelItemWritercreated by this builder.- Parameters:
inputChannel- the input channel- Returns:
- this builder instance for fluent chaining
- See Also:
-
outputChannel
public RemoteChunkingManagerBuilder 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 RemoteChunkingManagerBuilder messagingTemplate(org.springframework.integration.core.MessagingTemplate messagingTemplate) Set theMessagingTemplateto 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
Set the throttle limit. This limits the number of pending requests for chunk processing to avoid overwhelming the receivers. Defaults to 6.- Parameters:
throttleLimit- the throttle limit to set- Returns:
- this builder instance for fluent chaining
- See Also:
-
chunk
Create aChunkOrientedStepBuilderfor a manager step with the given chunk size. The item writer of the returned builder is aChunkMessageChannelItemWriterconfigured with the settings of this builder, and must not be changed.- Overrides:
chunkin classStepBuilder- Type Parameters:
I- the type of item to be processed as inputO- the type of item to be output- Parameters:
chunkSize- the chunk size (commit interval)- Returns:
- a
ChunkOrientedStepBuilderfor method chaining - Throws:
IllegalArgumentException- if no input channel is providedIllegalStateException- if both an output channel and a messaging template are provided, or if none of them is
-