Class UnicastingDispatcher
java.lang.Object
org.springframework.integration.dispatcher.AbstractDispatcher
org.springframework.integration.dispatcher.UnicastingDispatcher
- All Implemented Interfaces:
MessageDispatcher
Implementation of
MessageDispatcher
that will attempt to send a
Message
to at most one of its handlers. The handlers will be tried
as determined by the LoadBalancingStrategy
if one is configured. As
soon as one of the handlers accepts the Message, the dispatcher will
return true
and ignore the rest of its handlers.
If the dispatcher has no handlers, a MessageDispatchingException
will be
thrown. If all handlers throw Exceptions, the dispatcher will throw an
AggregateMessageDeliveryException
.
A load-balancing strategy may be provided to this class to control the order in which the handlers will be tried.
- Since:
- 1.0.2
- Author:
- Iwein Fuld, Mark Fisher, Gary Russell, Oleg Zhurakousky, Artem Bilan
-
Field Summary
Fields inherited from class org.springframework.integration.dispatcher.AbstractDispatcher
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Dispatch the message.void
setFailover
(boolean failover) Specify whether this dispatcher should failover when a singleMessageHandler
throws an Exception.void
setFailoverStrategy
(Predicate<Exception> failoverStrategy) Configure a strategy whether the channel's dispatcher should have failover enabled for the exception thrown.void
setLoadBalancingStrategy
(LoadBalancingStrategy loadBalancingStrategy) Provide aLoadBalancingStrategy
for this dispatcher.void
setMessageHandlingTaskDecorator
(MessageHandlingTaskDecorator messageHandlingTaskDecorator) Methods inherited from class org.springframework.integration.dispatcher.AbstractDispatcher
addHandler, getHandlerCount, getHandlers, removeHandler, setMaxSubscribers, toString, tryOptimizedDispatch
-
Constructor Details
-
UnicastingDispatcher
public UnicastingDispatcher() -
UnicastingDispatcher
-
-
Method Details
-
setFailover
public void setFailover(boolean failover) Specify whether this dispatcher should failover when a singleMessageHandler
throws an Exception. The default value istrue
. OverridessetFailoverStrategy(Predicate)
option. In other words: or this, or that option has to be set.- Parameters:
failover
- The failover boolean.
-
setFailoverStrategy
Configure 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
-
setLoadBalancingStrategy
Provide aLoadBalancingStrategy
for this dispatcher.- Parameters:
loadBalancingStrategy
- The load balancing strategy implementation.
-
setMessageHandlingTaskDecorator
public void setMessageHandlingTaskDecorator(MessageHandlingTaskDecorator messageHandlingTaskDecorator) -
dispatch
Description copied from interface:MessageDispatcher
Dispatch the message.- Parameters:
message
- the message.- Returns:
- true if dispatched.
-