Class BroadcastingDispatcher
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,MessageDispatcher
public class BroadcastingDispatcher extends AbstractDispatcher implements BeanFactoryAware
If the 'ignoreFailures' flag is set to true on the other hand, it will make a best effort to send the message to each of its handlers. In other words, when 'ignoreFailures' is true, if it fails to send to any one handler, it will simply log a warn-level message but continue to send the Message to any other handlers.
If the 'requireSubscribers' flag is set to true, the sent message is considered as non-dispatched
and rejected to the caller with the "Dispatcher has no subscribers"
MessageDispatchingException
.
- Author:
- Mark Fisher, Iwein Fuld, Gary Russell, Oleg Zhurakousky, Artem Bilan
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BroadcastingDispatcher()
BroadcastingDispatcher(boolean requireSubscribers)
BroadcastingDispatcher(Executor executor)
BroadcastingDispatcher(Executor executor, boolean requireSubscribers)
-
Method Summary
Modifier and Type Method Description boolean
dispatch(Message<?> message)
Dispatch the message.protected MessageBuilderFactory
getMessageBuilderFactory()
void
setApplySequence(boolean applySequence)
Specify whether to apply sequence numbers to the messages prior to sending to the handlers.void
setBeanFactory(BeanFactory beanFactory)
void
setIgnoreFailures(boolean ignoreFailures)
Specify whether failures for one or more of the handlers should be ignored.void
setMessageHandlingTaskDecorator(MessageHandlingTaskDecorator messageHandlingTaskDecorator)
void
setMinSubscribers(int minSubscribers)
If at least this number of subscribers receive the message,dispatch(Message)
will return true.Methods inherited from class org.springframework.integration.dispatcher.AbstractDispatcher
addHandler, getHandlerCount, getHandlers, removeHandler, setMaxSubscribers, toString, tryOptimizedDispatch
-
Constructor Details
-
BroadcastingDispatcher
public BroadcastingDispatcher() -
BroadcastingDispatcher
-
BroadcastingDispatcher
public BroadcastingDispatcher(boolean requireSubscribers) -
BroadcastingDispatcher
-
-
Method Details
-
setIgnoreFailures
public void setIgnoreFailures(boolean ignoreFailures)Specify whether failures for one or more of the handlers should be ignored. By default this is false meaning that an Exception will be thrown when a handler fails. To override this and suppress Exceptions, set the value to true.Keep in mind that when using an Executor, even without ignoring the failures, other handlers may be invoked after one throws an Exception. Since the Executor is most likely using a different thread, this flag would only affect whether an error Message is sent to the error channel or not in the case that such an Executor has been configured.
- Parameters:
ignoreFailures
- true when failures are to be ignored.
-
setApplySequence
public void setApplySequence(boolean applySequence)Specify whether to apply sequence numbers to the messages prior to sending to the handlers. By default, sequence numbers will not be applied.- Parameters:
applySequence
- true when sequence information should be applied.
-
setMinSubscribers
public void setMinSubscribers(int minSubscribers)If at least this number of subscribers receive the message,dispatch(Message)
will return true. Default: 0.- Parameters:
minSubscribers
- The minimum number of subscribers.
-
setMessageHandlingTaskDecorator
public void setMessageHandlingTaskDecorator(MessageHandlingTaskDecorator messageHandlingTaskDecorator) -
setBeanFactory
- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Throws:
BeansException
-
getMessageBuilderFactory
-
dispatch
Description copied from interface:MessageDispatcher
Dispatch the message.- Specified by:
dispatch
in interfaceMessageDispatcher
- Parameters:
message
- the message.- Returns:
- true if dispatched.
-