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<?>>
public class RecipientListRouter extends AbstractMessageRouter implements 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.
- Author:
- Mark Fisher, Oleg Zhurakousky, Artem Bilan, Liujiong, Gary Russell
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRecipientListRouter.RecipientNested 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, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors Constructor Description RecipientListRouter() -
Method Summary
Modifier and Type Method Description voidaddRecipient(String channelName)Add a recipient with channelName.voidaddRecipient(String channelName, String selectorExpression)Add a recipient with channelName and expression.voidaddRecipient(String channelName, MessageSelector selector)voidaddRecipient(MessageChannel channel)voidaddRecipient(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.StringgetComponentType()Subclasses may implement this method to provide component type information.IntegrationPatternTypegetIntegrationPatternType()Return a pattern type this component implements.Collection<RecipientListRouter.Recipient>getRecipients()protected voidonInit()Subclasses may implement this for initialization logic.intremoveRecipient(String channelName)Remove all recipients that match the channelName.intremoveRecipient(String channelName, String selectorExpression)Remove all recipients that match the channelName and expression.voidreplaceRecipients(Properties recipientMappings)Replace recipient.voidsetChannels(List<MessageChannel> channels)Set the channels for this router.voidsetRecipientMappings(Map<String,String> recipientMappings)Set the recipients for this router.voidsetRecipients(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, setSendTimeoutMethods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribeMethods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getManagedName, getManagedType, getMetricsCaptor, getOrder, getOverrides, isLoggingEnabled, registerMetricsCaptor, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAsMethods 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:
setRecipientMappingsin interfaceRecipientListRouterManagement- Parameters:
recipientMappings- map contains channelName and expression
-
addRecipient
Description copied from interface:RecipientListRouterManagementAdd a recipient with channelName and expression.- Specified by:
addRecipientin interfaceRecipientListRouterManagement- Parameters:
channelName- The channel name.selectorExpression- The expression to filter the incoming message.
-
addRecipient
Description copied from interface:RecipientListRouterManagementAdd a recipient with channelName.- Specified by:
addRecipientin interfaceRecipientListRouterManagement- Parameters:
channelName- The channel name.
-
addRecipient
-
addRecipient
-
addRecipient
-
removeRecipient
Description copied from interface:RecipientListRouterManagementRemove all recipients that match the channelName.- Specified by:
removeRecipientin interfaceRecipientListRouterManagement- Parameters:
channelName- The channel name.- Returns:
- The number of recipients removed.
-
removeRecipient
Description copied from interface:RecipientListRouterManagementRemove all recipients that match the channelName and expression.- Specified by:
removeRecipientin 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:RecipientListRouterManagementReplace recipient.- Specified by:
replaceRecipientsin interfaceRecipientListRouterManagement- Parameters:
recipientMappings- contain channelName and expression.
-
getRecipients
- Specified by:
getRecipientsin interfaceRecipientListRouterManagement- Returns:
- an unmodifiable collection of recipients.
-
getComponentType
Description copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classAbstractMessageRouter
-
getIntegrationPatternType
Description copied from interface:IntegrationPatternReturn a pattern type this component implements.- Specified by:
getIntegrationPatternTypein interfaceIntegrationPattern- Overrides:
getIntegrationPatternTypein classAbstractMessageRouter- Returns:
- the
IntegrationPatternTypethis component implements.
-
determineTargetChannels
Description copied from class:AbstractMessageRouterSubclasses must implement this method to return a Collection of zero or more MessageChannels to which the given Message should be routed.- Specified by:
determineTargetChannelsin classAbstractMessageRouter- Parameters:
message- The message.- Returns:
- The collection of message channels.
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classAbstractMessageRouter
-