org.springframework.integration.router
Class AbstractMessageRouter

java.lang.Object
  extended by org.springframework.integration.handler.AbstractMessageHandler
      extended by org.springframework.integration.router.AbstractMessageRouter
All Implemented Interfaces:
org.springframework.core.Ordered, MessageHandler
Direct Known Subclasses:
AbstractChannelNameResolvingMessageRouter, AbstractSingleChannelRouter

public abstract class AbstractMessageRouter
extends AbstractMessageHandler

Base class for Message Routers.

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
AbstractMessageRouter()
           
 
Method Summary
protected abstract  java.util.Collection<MessageChannel> determineTargetChannels(Message<?> message)
          Subclasses must implement this method to return the target channels for a given Message.
protected  void handleMessageInternal(Message<?> message)
           
 void setDefaultOutputChannel(MessageChannel defaultOutputChannel)
          Set the default channel where Messages should be sent if channel resolution fails to return any channels.
 void setResolutionRequired(boolean resolutionRequired)
          Set whether this router should always be required to resolve at least one channel.
 void setTimeout(long timeout)
          Set the timeout for sending a message to the resolved channel.
 
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
getOrder, handleMessage, setOrder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMessageRouter

public AbstractMessageRouter()
Method Detail

setDefaultOutputChannel

public void setDefaultOutputChannel(MessageChannel defaultOutputChannel)
Set the default channel where Messages should be sent if channel resolution fails to return any channels. If no default channel is provided, the router will either drop the Message or throw an Exception depending on the value of resolutionRequired.


setTimeout

public void setTimeout(long timeout)
Set the timeout for sending a message to the resolved channel. By default, there is no timeout, meaning the send will block indefinitely.


setResolutionRequired

public void setResolutionRequired(boolean resolutionRequired)
Set whether this router should always be required to resolve at least one channel. The default is 'false'. To trigger an exception whenever the resolver returns null or an empty channel list, and this endpoint has no 'defaultOutputChannel' configured, set this value to 'true'.


handleMessageInternal

protected void handleMessageInternal(Message<?> message)
Specified by:
handleMessageInternal in class AbstractMessageHandler

determineTargetChannels

protected abstract java.util.Collection<MessageChannel> determineTargetChannels(Message<?> message)
Subclasses must implement this method to return the target channels for a given Message.