Class AbstractMessageRouter

All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>, Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, Ordered, ExpressionCapable, Orderable, IntegrationPattern, MessageRouter, NamedComponent, IntegrationManagement, TrackableComponent, MessageHandler, reactor.core.CoreSubscriber<Message<?>>
Direct Known Subclasses:
AbstractMappingMessageRouter, RecipientListRouter

@ManagedResource @IntegrationManagedResource public abstract class AbstractMessageRouter extends AbstractMessageHandler implements MessageRouter
Base class for all Message Routers.
Author:
Mark Fisher, Oleg Zhurakousky, Gunnar Hillert, Soby Chacko, Stefan Ferstl, Artem Bilan
  • Constructor Details

    • AbstractMessageRouter

      public AbstractMessageRouter()
  • Method Details

    • 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 and channel resolution fails to return any channels, the router will throw an MessageDeliveryException.

      If messages shall be ignored (dropped) instead, please provide a NullChannel.

      Parameters:
      defaultOutputChannel - The default output channel.
    • getDefaultOutputChannel

      public MessageChannel getDefaultOutputChannel()
      Get the default output channel.
      Specified by:
      getDefaultOutputChannel in interface MessageRouter
      Returns:
      the channel.
      Since:
      4.3
    • setDefaultOutputChannelName

      public void setDefaultOutputChannelName(String defaultOutputChannelName)
    • setSendTimeout

      public void setSendTimeout(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.
      Parameters:
      timeout - The timeout.
      Since:
      4.3
    • setIgnoreSendFailures

      public void setIgnoreSendFailures(boolean ignoreSendFailures)
      Specify whether send failures for one or more of the recipients should be ignored. By default this is false meaning that an Exception will be thrown whenever a send fails. To override this and suppress Exceptions, set the value to true.
      Parameters:
      ignoreSendFailures - true to ignore send failures.
    • setApplySequence

      public void setApplySequence(boolean applySequence)
      Specify whether to apply the sequence number and size headers to the messages prior to sending to the recipient channels. By default, this value is false meaning that sequence headers will not be applied. If planning to use an Aggregator downstream with the default correlation and completion strategies, you should set this flag to true.
      Parameters:
      applySequence - true to apply sequence information.
    • getComponentType

      public String getComponentType()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this method to provide component type information.
      Specified by:
      getComponentType in interface NamedComponent
      Overrides:
      getComponentType in class MessageHandlerSupport
    • getIntegrationPatternType

      public IntegrationPatternType getIntegrationPatternType()
      Description copied from interface: IntegrationPattern
      Return a pattern type this component implements.
      Specified by:
      getIntegrationPatternType in interface IntegrationPattern
      Overrides:
      getIntegrationPatternType in class MessageHandlerSupport
      Returns:
      the IntegrationPatternType this component implements.
    • getMessagingTemplate

      protected MessagingTemplate getMessagingTemplate()
      Provide MessagingTemplate access for subclasses.
      Returns:
      The messaging template.
    • getRequiredConversionService

      protected ConversionService getRequiredConversionService()
    • onInit

      protected void onInit()
      Description copied from class: IntegrationObjectSupport
      Subclasses may implement this for initialization logic.
      Overrides:
      onInit in class IntegrationObjectSupport
    • determineTargetChannels

      protected abstract 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.
      Parameters:
      message - The message.
      Returns:
      The collection of message channels.
    • handleMessageInternal

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