Class AbstractMessageRouter

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

@ManagedResource
@IntegrationManagedResource
public abstract class AbstractMessageRouter
extends AbstractMessageHandler
implements MessageRouter
Base class for all Message Routers.
  • Constructor Details

  • Method Details

    • setDefaultOutputChannel

      public void setDefaultOutputChannel​(org.springframework.messaging.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 org.springframework.messaging.MessageChannel getDefaultOutputChannel()
      Get the default output channel.
      Specified by:
      getDefaultOutputChannel in interface MessageRouter
      Returns:
      the channel.
      Since:
      4.3
    • setDefaultOutputChannelName

      public void setDefaultOutputChannelName​(java.lang.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 java.lang.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 org.springframework.core.convert.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 java.util.Collection<org.springframework.messaging.MessageChannel> determineTargetChannels​(org.springframework.messaging.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​(org.springframework.messaging.Message<?> message)
      Specified by:
      handleMessageInternal in class AbstractMessageHandler