org.springframework.integration.router
Class RecipientListRouter

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.handler.AbstractMessageHandler
          extended by org.springframework.integration.router.AbstractMessageRouter
              extended by org.springframework.integration.router.RecipientListRouter
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.core.Ordered, MessageHandler, ComponentMetadataProvider

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, a map with MessageSelector instances as the keys and collections of channels as the values can be provided via the setChannelMap(Map) method.

For more advanced, programmatic control of dynamic recipient lists, consider using the @Router annotation or extending AbstractChannelNameResolvingMessageRouter 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

Field Summary
 
Fields inherited from class org.springframework.integration.handler.AbstractMessageHandler
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
RecipientListRouter()
           
 
Method Summary
protected  java.util.Collection<MessageChannel> determineTargetChannels(Message<?> message)
          Subclasses must implement this method to return the target channels for a given Message.
 void onInit()
          Subclasses may implement this for initialization logic.
protected  void populateComponentMetadata(ComponentMetadata metadata)
          Subclasses may override this to add attributes to the ComponentMetadata.
 void setChannelMap(java.util.Map<MessageSelector,? extends java.util.Collection<MessageChannel>> channelMap)
          Set a custom map of selectors to channels.
 void setChannels(java.util.List<MessageChannel> channels)
          Set the output channels of this router.
 
Methods inherited from class org.springframework.integration.router.AbstractMessageRouter
handleMessageInternal, setApplySequence, setDefaultOutputChannel, setIgnoreSendFailures, setResolutionRequired, setTimeout
 
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
getOrder, handleMessage, resolveReplyChannel, setOrder
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getBeanName, getChannelResolver, getComponentMetadata, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setChannelResolver, setConversionService, setTaskScheduler, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
 

Constructor Detail

RecipientListRouter

public RecipientListRouter()
Method Detail

setChannels

public void setChannels(java.util.List<MessageChannel> channels)
Set the output channels of this router.

Parameters:
channels -

setChannelMap

public void setChannelMap(java.util.Map<MessageSelector,? extends java.util.Collection<MessageChannel>> channelMap)
Set a custom map of selectors to channels. This allows a configuration where groups of channels are used for messages matching a particular filter.

Parameters:
channelMap -

populateComponentMetadata

protected void populateComponentMetadata(ComponentMetadata metadata)
Description copied from class: IntegrationObjectSupport
Subclasses may override this to add attributes to the ComponentMetadata.

Overrides:
populateComponentMetadata in class AbstractMessageRouter

onInit

public final void onInit()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class IntegrationObjectSupport

determineTargetChannels

protected java.util.Collection<MessageChannel> determineTargetChannels(Message<?> message)
Description copied from class: AbstractMessageRouter
Subclasses must implement this method to return the target channels for a given Message.

Specified by:
determineTargetChannels in class AbstractMessageRouter