类 MessageChannelPartitionHandler
- java.lang.Object
- org.springframework.batch.integration.partition.MessageChannelPartitionHandler
 
- 所有已实现的接口:
- PartitionHandler,- org.springframework.beans.factory.InitializingBean
 - @MessageEndpoint public class MessageChannelPartitionHandler extends java.lang.Object implements PartitionHandler, org.springframework.beans.factory.InitializingBean A- PartitionHandlerthat uses- MessageChannelinstances to send instructions to remote workers and receive their responses. The- MessageChannelprovides a nice abstraction so that the location of the workers and the transport used to communicate with them can be changed at run time. The communication with the remote workers does not need to be transactional or have guaranteed delivery, so a local thread pool based implementation works as well as a remote web service or JMS implementation. If a remote worker fails, the job will fail and can be restarted to pick up missing messages and processing. The remote workers need access to the Spring Batch- JobRepositoryso that the shared state across those restarts can be managed centrally. While a- MessageChannelis used for sending the requests to the workers, the worker's responses can be obtained in one of two ways:- A reply channel - Slaves will respond with messages that will be aggregated via this component.
- Polling the job repository - Since the state of each slave is maintained independently within the job repository, we can poll the store to determine the state without the need of the slaves to formally respond.
 - 作者:
- Dave Syer, Will Schipp, Michael Minella, Mahmoud Ben Hassine
 
- 构造器概要- 构造器 - 构造器 - 说明 - MessageChannelPartitionHandler()
 - 方法概要- 所有方法 实例方法 具体方法 - 修饰符和类型 - 方法 - 说明 - void- afterPropertiesSet()- java.util.List<?>- aggregate(java.util.List<?> messages)- java.util.Collection<StepExecution>- handle(StepExecutionSplitter stepExecutionSplitter, StepExecution masterStepExecution)Sends- StepExecutionRequestobjects to the request channel of the- MessagingTemplate, and then receives the result back as a list of- StepExecutionon a reply channel.- void- setDataSource(javax.sql.DataSource dataSource)- DataSourcepointing to the job repository- void- setGridSize(int gridSize)Passed to the- StepExecutionSplitterin the- handle(StepExecutionSplitter, StepExecution)method, instructing it how many- StepExecutioninstances are required, ideally.- void- setJobExplorer(JobExplorer jobExplorer)- JobExplorerto use to query the job repository.- void- setMessagingOperations(org.springframework.integration.core.MessagingTemplate messagingGateway)A pre-configured gateway for sending and receiving messages to the remote workers.- void- setPollInterval(long pollInterval)How often to poll the job repository for the status of the slaves.- void- setReplyChannel(org.springframework.messaging.PollableChannel replyChannel)- void- setStepName(java.lang.String stepName)The name of the- Stepthat will be used to execute the partitioned- StepExecution.- void- setTimeout(long timeout)When using job repository polling, the time limit to wait.
 
- 构造器详细资料- MessageChannelPartitionHandler- public MessageChannelPartitionHandler() 
 
 - 方法详细资料- afterPropertiesSet- public void afterPropertiesSet() throws java.lang.Exception - 指定者:
- afterPropertiesSet在接口中- org.springframework.beans.factory.InitializingBean
- 抛出:
- java.lang.Exception
 
 - setTimeout- public void setTimeout(long timeout) When using job repository polling, the time limit to wait.- 参数:
- timeout- milliseconds to wait, defaults to -1 (no timeout).
 
 - setJobExplorer- public void setJobExplorer(JobExplorer jobExplorer) - JobExplorerto use to query the job repository. Either this or a- DataSourceis required when using job repository polling.- 参数:
- jobExplorer-- JobExplorerto use for lookups
 
 - setPollInterval- public void setPollInterval(long pollInterval) How often to poll the job repository for the status of the slaves.- 参数:
- pollInterval- milliseconds between polls, defaults to 10000 (10 seconds).
 
 - setDataSource- public void setDataSource(javax.sql.DataSource dataSource) - DataSourcepointing to the job repository- 参数:
- dataSource-- DataSourcethat points to the job repository's store
 
 - setMessagingOperations- public void setMessagingOperations(org.springframework.integration.core.MessagingTemplate messagingGateway) A pre-configured gateway for sending and receiving messages to the remote workers. Using this property allows a large degree of control over the timeouts and other properties of the send. It should have channels set up internally:- request channel capable of accepting StepExecutionRequestpayloads
- reply channel that returns a list of StepExecutionresults
 - 参数:
- messagingGateway- the- MessagingTemplateto set
 
- request channel capable of accepting 
 - setGridSize- public void setGridSize(int gridSize) Passed to the- StepExecutionSplitterin the- handle(StepExecutionSplitter, StepExecution)method, instructing it how many- StepExecutioninstances are required, ideally. The- StepExecutionSplitteris allowed to ignore the grid size in the case of a restart, since the input data partitions must be preserved.- 参数:
- gridSize- the number of step executions that will be created
 
 - setStepName- public void setStepName(java.lang.String stepName) The name of the- Stepthat will be used to execute the partitioned- StepExecution. This is a regular Spring Batch step, with all the business logic required to complete an execution based on the input parameters in its- StepExecutioncontext. The name will be translated into a- Stepinstance by the remote worker.- 参数:
- stepName- the name of the- Stepinstance to execute business logic
 
 - aggregate- @Aggregator(sendPartialResultsOnExpiry="true") public java.util.List<?> aggregate(@Payloads java.util.List<?> messages) - 参数:
- messages- the messages to be aggregated
- 返回:
- the list as it was passed in
 
 - setReplyChannel- public void setReplyChannel(org.springframework.messaging.PollableChannel replyChannel) 
 - handle- public java.util.Collection<StepExecution> handle(StepExecutionSplitter stepExecutionSplitter, StepExecution masterStepExecution) throws java.lang.Exception Sends- StepExecutionRequestobjects to the request channel of the- MessagingTemplate, and then receives the result back as a list of- StepExecutionon a reply channel. Use the- aggregate(List)method as an aggregator of the individual remote replies. The receive timeout needs to be set realistically in the- MessagingTemplateand the aggregator, so that there is a good chance of all work being done.- 指定者:
- handle在接口中- PartitionHandler
- 参数:
- stepExecutionSplitter- a strategy for generating a collection of- StepExecutioninstances
- masterStepExecution- the master step execution for the whole partition
- 返回:
- a collection of completed StepExecutioninstances
- 抛出:
- java.lang.Exception- if anything goes wrong. This allows implementations to be liberal and rely on the caller to translate an exception into a step failure as necessary.
- 另请参阅:
- PartitionHandler.handle(StepExecutionSplitter, StepExecution)