public class RecipientListRouter extends AbstractMessageRouter implements org.springframework.beans.factory.InitializingBean, RecipientListRouterManagement
<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 |
IntegrationManagement.ManagementOverridesEXPRESSION_PARSER, loggerMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME| Constructor and Description |
|---|
RecipientListRouter() |
| Modifier and Type | Method and Description |
|---|---|
void |
addRecipient(org.springframework.messaging.MessageChannel channel) |
void |
addRecipient(org.springframework.messaging.MessageChannel channel,
MessageSelector selector) |
void |
addRecipient(java.lang.String channelName)
Add a recipient with channelName.
|
void |
addRecipient(java.lang.String channelName,
MessageSelector selector) |
void |
addRecipient(java.lang.String channelName,
java.lang.String selectorExpression)
Add a recipient with channelName and expression.
|
protected java.util.Collection<org.springframework.messaging.MessageChannel> |
determineTargetChannels(org.springframework.messaging.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.
|
java.util.Collection<RecipientListRouter.Recipient> |
getRecipients() |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
int |
removeRecipient(java.lang.String channelName)
Remove all recipients that match the channelName.
|
int |
removeRecipient(java.lang.String channelName,
java.lang.String selectorExpression)
Remove all recipients that match the channelName and expression.
|
void |
replaceRecipients(java.util.Properties recipientMappings)
Replace recipient.
|
void |
setChannels(java.util.List<org.springframework.messaging.MessageChannel> channels)
Set the channels for this router.
|
void |
setRecipientMappings(java.util.Map<java.lang.String,java.lang.String> recipientMappings)
Set the recipients for this router.
|
void |
setRecipients(java.util.List<RecipientListRouter.Recipient> recipients)
Set the recipients for this router.
|
getDefaultOutputChannel, getMessagingTemplate, getRequiredConversionService, handleMessageInternal, setApplySequence, setDefaultOutputChannel, setDefaultOutputChannelName, setIgnoreSendFailures, setSendTimeoutconfigureMetrics, getActiveCount, getActiveCountLong, getDuration, getErrorCount, getErrorCountLong, getHandleCount, getHandleCountLong, getManagedName, getManagedType, getMaxDuration, getMeanDuration, getMinDuration, getOrder, getOverrides, getStandardDeviationDuration, handleMessage, isCountsEnabled, isLoggingEnabled, isStatsEnabled, onComplete, onError, onNext, onSubscribe, registerMetricsCaptor, reset, setCountsEnabled, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, setStatsEnabledafterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitafterPropertiesSetgetComponentNamepublic void setChannels(java.util.List<org.springframework.messaging.MessageChannel> channels)
setRecipients(List) but not both. If MessageSelectors should be
considered, then use setRecipients(List).channels - The channels.public void setRecipients(java.util.List<RecipientListRouter.Recipient> recipients)
recipients - The recipients.@ManagedAttribute public void setRecipientMappings(java.util.Map<java.lang.String,java.lang.String> recipientMappings)
setRecipientMappings in interface RecipientListRouterManagementrecipientMappings - map contains channelName and expression@ManagedOperation
public void addRecipient(java.lang.String channelName,
java.lang.String selectorExpression)
RecipientListRouterManagementaddRecipient in interface RecipientListRouterManagementchannelName - The channel name.selectorExpression - The expression to filter the incoming message.@ManagedOperation public void addRecipient(java.lang.String channelName)
RecipientListRouterManagementaddRecipient in interface RecipientListRouterManagementchannelName - The channel name.public void addRecipient(java.lang.String channelName,
MessageSelector selector)
public void addRecipient(org.springframework.messaging.MessageChannel channel)
public void addRecipient(org.springframework.messaging.MessageChannel channel,
MessageSelector selector)
@ManagedOperation public int removeRecipient(java.lang.String channelName)
RecipientListRouterManagementremoveRecipient in interface RecipientListRouterManagementchannelName - The channel name.@ManagedOperation
public int removeRecipient(java.lang.String channelName,
java.lang.String selectorExpression)
RecipientListRouterManagementremoveRecipient in interface RecipientListRouterManagementchannelName - The channel name.selectorExpression - The expression to filter the incoming message@ManagedOperation public void replaceRecipients(java.util.Properties recipientMappings)
RecipientListRouterManagementreplaceRecipients in interface RecipientListRouterManagementrecipientMappings - contain channelName and expression.@ManagedAttribute public java.util.Collection<RecipientListRouter.Recipient> getRecipients()
getRecipients in interface RecipientListRouterManagementpublic java.lang.String getComponentType()
IntegrationObjectSupportgetComponentType in interface NamedComponentgetComponentType in class AbstractMessageRouterprotected java.util.Collection<org.springframework.messaging.MessageChannel> determineTargetChannels(org.springframework.messaging.Message<?> message)
AbstractMessageRouterdetermineTargetChannels in class AbstractMessageRoutermessage - The message.protected void onInit()
throws java.lang.Exception
IntegrationObjectSupportonInit in class AbstractMessageRouterjava.lang.Exception - Any exception.