Class PartitionedDispatcher
java.lang.Object
org.springframework.integration.dispatcher.AbstractDispatcher
org.springframework.integration.dispatcher.PartitionedDispatcher
- All Implemented Interfaces:
- MessageDispatcher
An 
AbstractDispatcher implementation for distributing messages to
 dedicated threads according to the key determined by the provided function against
 the message to dispatch.
 
 Every partition, created by this class, is a UnicastingDispatcher
 delegate based on a single thread Executor.
 
The number of partitions should be a reasonable value for the application environment since every partition is based on a dedicated thread for message processing.
 The rest of the logic is similar to UnicastingDispatcher behavior.
- Since:
- 6.1
- Author:
- Artem Bilan, Christian Tzolov
- 
Field SummaryFields inherited from class org.springframework.integration.dispatcher.AbstractDispatcherlogger
- 
Constructor SummaryConstructorsConstructorDescriptionPartitionedDispatcher(int partitionCount, Function<Message<?>, Object> partitionKeyFunction) Instantiate based on a provided number of partitions and function for partition key against the message to dispatch.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanDispatch the message.voidsetErrorHandler(ErrorHandler errorHandler) voidsetFailover(boolean failover) Specify whether partition dispatchers should have failover enabled.voidsetFailoverStrategy(Predicate<Exception> failoverStrategy) Configure a strategy whether the channel's dispatcher should have failover enabled for the exception thrown.voidsetLoadBalancingStrategy(LoadBalancingStrategy loadBalancingStrategy) Provide aLoadBalancingStrategyfor partition dispatchers.voidsetMessageHandlingTaskDecorator(MessageHandlingTaskDecorator messageHandlingTaskDecorator) Set aMessageHandlingTaskDecoratorto wrap a message handling task into some addition logic, e.g.voidsetThreadFactory(ThreadFactory threadFactory) Set aThreadFactoryfor executors per partitions.voidshutdown()Shutdown this dispatcher on application close.Methods inherited from class org.springframework.integration.dispatcher.AbstractDispatcheraddHandler, getHandlerCount, getHandlers, removeHandler, setMaxSubscribers, toString, tryOptimizedDispatch
- 
Constructor Details- 
PartitionedDispatcherInstantiate based on a provided number of partitions and function for partition key against the message to dispatch.- Parameters:
- partitionCount- the number of partitions in this channel.
- partitionKeyFunction- the function to resolve a partition key against the message to dispatch.
 
 
- 
- 
Method Details- 
setThreadFactorySet aThreadFactoryfor executors per partitions. Defaults to theCustomizableThreadFactorybased on apartition-thread-prefix.- Parameters:
- threadFactory- the- ThreadFactoryto use.
 
- 
setFailoverpublic void setFailover(boolean failover) Specify whether partition dispatchers should have failover enabled. By default, it will. Set this value to 'false' to disable it.- Parameters:
- failover- The failover boolean.
 
- 
setFailoverStrategyConfigure a strategy whether the channel's dispatcher should have failover enabled for the exception thrown. OverridessetFailover(boolean)option. In other words: or this, or that option has to be set.- Parameters:
- failoverStrategy- The failover boolean.
- Since:
- 6.3
 
- 
setLoadBalancingStrategyProvide aLoadBalancingStrategyfor partition dispatchers.- Parameters:
- loadBalancingStrategy- The load balancing strategy implementation.
 
- 
setErrorHandler- Parameters:
- errorHandler- the- ErrorHandlerto use.
 
- 
setMessageHandlingTaskDecoratorpublic void setMessageHandlingTaskDecorator(MessageHandlingTaskDecorator messageHandlingTaskDecorator) Set aMessageHandlingTaskDecoratorto wrap a message handling task into some addition logic, e.g. message channel may provide an interception for its operations.- Parameters:
- messageHandlingTaskDecorator- the- MessageHandlingTaskDecoratorto use.
 
- 
shutdownpublic void shutdown()Shutdown this dispatcher on application close. The partition executors are shutdown and internal state of this instance is cleared.
- 
dispatchDescription copied from interface:MessageDispatcherDispatch the message.- Parameters:
- message- the message.
- Returns:
- true if dispatched.
 
 
-