public class RecipientListRouter extends AbstractMessageRouter implements org.springframework.beans.factory.InitializingBean
<recipient-list-router id="simpleRouter" input-channel="routingChannelA">
<recipient channel="channel1"/>
<recipient channel="channel2"/>
</recipient-list-router>
A Message Router that sends Messages to a list of recipient channels. The
recipients can be provided as a static list of MessageChannel
instances via the setChannels(List)
method, or for dynamic behavior,
the values can be provided via the setRecipients(List)
method.
For more advanced, programmatic control of dynamic recipient lists, consider
using the @Router annotation or extending AbstractMappingMessageRouter
instead.
Contrary to a standard <router .../> this handler will try to send to all channels that are configured as recipients. It is to channels what a publish subscribe channel is to endpoints.
Using this class only makes sense if it is essential to send messages on multiple channels instead of sending them to multiple handlers. If the latter is an option using a publish subscribe channel is the more flexible solution.
Modifier and Type | Class and Description |
---|---|
static class |
RecipientListRouter.Recipient |
logger
Constructor and Description |
---|
RecipientListRouter() |
Modifier and Type | Method and Description |
---|---|
protected java.util.Collection<MessageChannel> |
determineTargetChannels(Message<?> message)
Subclasses must implement this method to return a Collection of zero or more
MessageChannels to which the given Message should be routed.
|
java.lang.String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
void |
onInit()
Subclasses may implement this for initialization logic.
|
void |
setChannels(java.util.List<MessageChannel> channels)
Set the channels for this router.
|
void |
setRecipients(java.util.List<RecipientListRouter.Recipient> recipients)
Set the recipients for this router.
|
getMessagingTemplate, getRequiredConversionService, handleMessageInternal, setApplySequence, setDefaultOutputChannel, setIgnoreSendFailures, setTimeout
getOrder, handleMessage, setOrder, setShouldTrack
afterPropertiesSet, getApplicationContextId, getBeanFactory, getComponentName, getConversionService, getIntegrationProperties, getIntegrationProperty, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setComponentName, setConversionService, setTaskScheduler, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
afterPropertiesSet
getComponentName
public void setChannels(java.util.List<MessageChannel> channels)
setRecipients(List)
but not both. If MessageSelectors should be
considered, then use setRecipients(List)
.public void setRecipients(java.util.List<RecipientListRouter.Recipient> recipients)
public java.lang.String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class AbstractMessageRouter
public final void onInit()
IntegrationObjectSupport
onInit
in class IntegrationObjectSupport
protected java.util.Collection<MessageChannel> determineTargetChannels(Message<?> message)
AbstractMessageRouter
determineTargetChannels
in class AbstractMessageRouter