Class RemoteChunkingManagerBuilder


public class RemoteChunkingManagerBuilder extends StepBuilder
Builder for the manager side of a remote chunking setup. The manager step is a regular 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 ChunkOrientedStepBuilder returned by chunk(int).
  • Only chunk(int) configures a remote chunking manager step. Other methods inherited from StepBuilder that 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:
  • Constructor Details

    • RemoteChunkingManagerBuilder

      public RemoteChunkingManagerBuilder(String name, JobRepository jobRepository)
      Parameters:
      name - name of the manager step
      jobRepository - 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 the ChunkMessageChannelItemWriter created 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 the MessagingTemplate 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

      public RemoteChunkingManagerBuilder 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. 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 RemoteChunkingManagerBuilder throttleLimit(long 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

      public <I,O> ChunkOrientedStepBuilder<I,O> chunk(int chunkSize)
      Create a ChunkOrientedStepBuilder for a manager step with the given chunk size. The item writer of the returned builder is a ChunkMessageChannelItemWriter configured with the settings of this builder, and must not be changed.
      Overrides:
      chunk in class StepBuilder
      Type Parameters:
      I - the type of item to be processed as input
      O - the type of item to be output
      Parameters:
      chunkSize - the chunk size (commit interval)
      Returns:
      a ChunkOrientedStepBuilder for method chaining
      Throws:
      IllegalArgumentException - if no input channel is provided
      IllegalStateException - if both an output channel and a messaging template are provided, or if none of them is