Class RecipientListRouter
- All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Ordered
,ExpressionCapable
,Orderable
,IntegrationPattern
,MessageRouter
,RecipientListRouterManagement
,NamedComponent
,IntegrationManagement
,TrackableComponent
,MessageHandler
,reactor.core.CoreSubscriber<Message<?>>
<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.
- Author:
- Mark Fisher, Oleg Zhurakousky, Artem Bilan, Liujiong, Gary Russell
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addRecipient
(String channelName) Add a recipient with channelName.void
addRecipient
(String channelName, String selectorExpression) Add a recipient with channelName and expression.void
addRecipient
(String channelName, MessageSelector selector) void
addRecipient
(MessageChannel channel) void
addRecipient
(MessageChannel channel, MessageSelector selector) protected 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.Subclasses may implement this method to provide component type information.Return a pattern type this component implements.protected void
onInit()
Subclasses may implement this for initialization logic.int
removeRecipient
(String channelName) Remove all recipients that match the channelName.int
removeRecipient
(String channelName, String selectorExpression) Remove all recipients that match the channelName and expression.void
replaceRecipients
(Properties recipientMappings) Replace recipient.void
setChannels
(List<MessageChannel> channels) Set the channels for this router.void
setRecipientMappings
(Map<String, String> recipientMappings) Set the recipients for this router.void
setRecipients
(List<RecipientListRouter.Recipient> recipients) Set the recipients for this router.Methods inherited from class org.springframework.integration.router.AbstractMessageRouter
getDefaultOutputChannel, getMessagingTemplate, getRequiredConversionService, handleMessageInternal, setApplySequence, setDefaultOutputChannel, setDefaultOutputChannelName, setIgnoreSendFailures, setSendTimeout
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConvention
Methods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface reactor.core.CoreSubscriber
currentContext
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
RecipientListRouter
public RecipientListRouter()
-
-
Method Details
-
setChannels
Set the channels for this router. Either call this method orsetRecipients(List)
but not both. If MessageSelectors should be considered, then usesetRecipients(List)
.- Parameters:
channels
- The channels.
-
setRecipients
Set the recipients for this router.- Parameters:
recipients
- The recipients.
-
setRecipientMappings
Set the recipients for this router.- Specified by:
setRecipientMappings
in interfaceRecipientListRouterManagement
- Parameters:
recipientMappings
- map contains channelName and expression
-
addRecipient
Description copied from interface:RecipientListRouterManagement
Add a recipient with channelName and expression.- Specified by:
addRecipient
in interfaceRecipientListRouterManagement
- Parameters:
channelName
- The channel name.selectorExpression
- The expression to filter the incoming message.
-
addRecipient
Description copied from interface:RecipientListRouterManagement
Add a recipient with channelName.- Specified by:
addRecipient
in interfaceRecipientListRouterManagement
- Parameters:
channelName
- The channel name.
-
addRecipient
-
addRecipient
-
addRecipient
-
removeRecipient
Description copied from interface:RecipientListRouterManagement
Remove all recipients that match the channelName.- Specified by:
removeRecipient
in interfaceRecipientListRouterManagement
- Parameters:
channelName
- The channel name.- Returns:
- The number of recipients removed.
-
removeRecipient
Description copied from interface:RecipientListRouterManagement
Remove all recipients that match the channelName and expression.- Specified by:
removeRecipient
in interfaceRecipientListRouterManagement
- Parameters:
channelName
- The channel name.selectorExpression
- The expression to filter the incoming message- Returns:
- The number of recipients removed.
-
replaceRecipients
Description copied from interface:RecipientListRouterManagement
Replace recipient.- Specified by:
replaceRecipients
in interfaceRecipientListRouterManagement
- Parameters:
recipientMappings
- contain channelName and expression.
-
getRecipients
- Specified by:
getRecipients
in interfaceRecipientListRouterManagement
- Returns:
- an unmodifiable collection of recipients.
-
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classAbstractMessageRouter
-
getIntegrationPatternType
Description copied from interface:IntegrationPattern
Return a pattern type this component implements.- Specified by:
getIntegrationPatternType
in interfaceIntegrationPattern
- Overrides:
getIntegrationPatternType
in classAbstractMessageRouter
- Returns:
- the
IntegrationPatternType
this component implements.
-
determineTargetChannels
Description copied from class:AbstractMessageRouter
Subclasses must implement this method to return a Collection of zero or more MessageChannels to which the given Message should be routed.- Specified by:
determineTargetChannels
in classAbstractMessageRouter
- Parameters:
message
- The message.- Returns:
- The collection of message channels.
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classAbstractMessageRouter
-