Class ChunkMessageChannelItemWriter<T>
java.lang.Object
org.springframework.batch.integration.chunk.ChunkMessageChannelItemWriter<T>
- All Implemented Interfaces:
org.springframework.batch.core.listener.StepExecutionListener, org.springframework.batch.core.listener.StepListener, org.springframework.batch.infrastructure.item.ItemStream, org.springframework.batch.infrastructure.item.ItemWriter<T>, StepContributionSource
@NullUnmarked
public class ChunkMessageChannelItemWriter<T>
extends Object
implements org.springframework.batch.core.listener.StepExecutionListener, org.springframework.batch.infrastructure.item.ItemWriter<T>, org.springframework.batch.infrastructure.item.ItemStream, StepContributionSource
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected static final longprotected final ChunkMessageChannelItemWriter.LocalStateprotected intprotected org.springframework.integration.core.MessagingTemplateprotected org.springframework.messaging.PollableChannelprotected long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.batch.core.ExitStatusafterStep(org.springframework.batch.core.step.StepExecution stepExecution) voidbeforeStep(org.springframework.batch.core.step.StepExecution stepExecution) voidclose()protected voidGet the next result if it is available (within the timeout specified in the gateway), otherwise do nothing.Collection<org.springframework.batch.core.step.StepContribution> Get the currently available contributions and drain the source.voidopen(org.springframework.batch.infrastructure.item.ExecutionContext executionContext) voidsetMaxWaitTimeouts(int maxWaitTimeouts) The maximum number of times to wait at the end of a step for a non-null result from the remote workers.voidsetMessagingOperations(org.springframework.integration.core.MessagingTemplate messagingGateway) voidsetReplyChannel(org.springframework.messaging.PollableChannel replyChannel) voidsetThrottleLimit(long throttleLimit) Public setter for the throttle limit.voidupdate(org.springframework.batch.infrastructure.item.ExecutionContext executionContext) protected booleanWait until all the results that are in the pipeline come back to the reply channel.protected static AsynchronousFailureExceptionwrapIfNecessary(Throwable throwable) Re-throws the original throwable if it is unchecked, wraps checked exceptions intoAsynchronousFailureException.void
-
Field Details
-
DEFAULT_THROTTLE_LIMIT
protected static final long DEFAULT_THROTTLE_LIMIT- See Also:
-
messagingGateway
protected org.springframework.integration.core.MessagingTemplate messagingGateway -
localState
-
throttleLimit
protected long throttleLimit -
DEFAULT_MAX_WAIT_TIMEOUTS
protected final int DEFAULT_MAX_WAIT_TIMEOUTS- See Also:
-
maxWaitTimeouts
protected int maxWaitTimeouts -
replyChannel
protected org.springframework.messaging.PollableChannel replyChannel
-
-
Constructor Details
-
ChunkMessageChannelItemWriter
public ChunkMessageChannelItemWriter()
-
-
Method Details
-
setMaxWaitTimeouts
public void setMaxWaitTimeouts(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
-
setThrottleLimit
public void setThrottleLimit(long 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
-
setMessagingOperations
public void setMessagingOperations(org.springframework.integration.core.MessagingTemplate messagingGateway) -
setReplyChannel
public void setReplyChannel(org.springframework.messaging.PollableChannel replyChannel) -
write
-
beforeStep
public void beforeStep(org.springframework.batch.core.step.StepExecution stepExecution) - Specified by:
beforeStepin interfaceorg.springframework.batch.core.listener.StepExecutionListener
-
afterStep
public org.springframework.batch.core.ExitStatus afterStep(org.springframework.batch.core.step.StepExecution stepExecution) - Specified by:
afterStepin interfaceorg.springframework.batch.core.listener.StepExecutionListener
-
close
public void close() throws org.springframework.batch.infrastructure.item.ItemStreamException- Specified by:
closein interfaceorg.springframework.batch.infrastructure.item.ItemStream- Throws:
org.springframework.batch.infrastructure.item.ItemStreamException
-
open
public void open(org.springframework.batch.infrastructure.item.ExecutionContext executionContext) throws org.springframework.batch.infrastructure.item.ItemStreamException - Specified by:
openin interfaceorg.springframework.batch.infrastructure.item.ItemStream- Throws:
org.springframework.batch.infrastructure.item.ItemStreamException
-
update
public void update(org.springframework.batch.infrastructure.item.ExecutionContext executionContext) throws org.springframework.batch.infrastructure.item.ItemStreamException - Specified by:
updatein interfaceorg.springframework.batch.infrastructure.item.ItemStream- Throws:
org.springframework.batch.infrastructure.item.ItemStreamException
-
getStepContributions
Description copied from interface:StepContributionSourceGet the currently available contributions and drain the source. The next call would return an empty collection, unless new contributions have arrived.- Specified by:
getStepContributionsin interfaceStepContributionSource- Returns:
- a collection of
StepContributioninstances
-
waitForResults
Wait until all the results that are in the pipeline come back to the reply channel.- Returns:
- true if successfully received a result, false if timed out
- Throws:
AsynchronousFailureException
-
getNextResult
Get the next result if it is available (within the timeout specified in the gateway), otherwise do nothing.- Throws:
AsynchronousFailureException- If there is a response and it contains a failed chunk response.IllegalStateException- if the result contains the wrong job instance id (maybe we are sharing a channel and we shouldn't be)
-
wrapIfNecessary
Re-throws the original throwable if it is unchecked, wraps checked exceptions intoAsynchronousFailureException.
-